You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: write_buscreator.m
    path of file: ./repos/cocoSim-deprecated/src/middleEnd
    
    the code of the file until where you have to start completion: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This file is part of CoCoSim.
% Copyright (C) 2014-2016  Carnegie Mellon University
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% BusCreator block
%
% Creates a bus from a set of input values.
%
%% Generation scheme
% Every example is provided for 2 elements as input of respective data types scalar, vector of 2 elements and scalar.
% The output is a
    
function [output_string] = write_buscreator(unbloc, inter_blk, non_virtual)

output_string = '';

[list_out] = list_var_sortie(unbloc);
[list_in] = list_var_entree(unbloc, inter_blk);

non_virtual = strcmp(non_virtual, 'on');
[is_bus bus] = BusUtils.is_bus(unbloc.outports_dt{1});
is_virtual = ~is_bus;

if non_virtual
	nb_assigned = 0;
	for idx_elem=1:numel(bus.Elements)
		elem = bus.Elements(idx_elem);
		field_name = elem.Name;
		if numel(elem.Dimensions) == 1
			for idx_dim=1:elem.Dimensions
				output_string = app_sprintf(output_string, '\t%s.%s_%d = %s;\n', list_out{1}, field_name, idx_dim, list_in{idx_dim + nb_assigned});
			end