Hello,
As a part of my homework task, I need to write a function that formats an existing string with given variables which may be vectors or scalars and returns it in one cell array. for example,
num_participants = 3, experiment_num = 8:10
the output should look like, with no spaces:
exp experiment_number_sub10 participant number
exp8_sub101
exp8_sub102
...
exp_10sub103
and all of this output should be in one cell array. So I figured out two ways and then got stuck:
experiment_num = 8:10
num_participants = 3
f = cellstr(num2str((experiment_num)', 'exp%d_'))
f2 = cellstr(num2str(([1:num_participants])', 'sub10%d'))
This works perfectly fine but I couldn't find a way to concatanate the two cell arrays into one (not in two coloumns but in one column)
and
mat = [experiment_num',(1:num_participants)']
list = sprintf('exp%d_sub10%d\n', mat)
only my output, in this case, is not in the right order
list =
'exp8_sub109
exp10_sub101
exp2_sub103
'
though the columns themselves are aligned properly.
Your help is much appreciated (I read the documentation and googled anything I could, but I cannot understand how to proceed.
Thank you