I am a beginner in MATLAB and I hope that I will find the help (again :) ) in this nice website. It is about model prediction results for a series of individuals. therefore, I have a series of variables (containing the basic results of each Individual) and which their nomenclature differ only in the first part ..e,g:
Mike results saved as: Mike_Sim_V_software1 Adam results saved as: Adam_Sim_V_sofwtare1 Sarah results saved as: Sarah_Sim_V_sofwtare1 and so on ...
I already have the list of names ['Mike','Adam','Sarah', etc.] and the ID (%saved in the variable named: idx)
and Because I want to excute a series of calculations which is similar for all the above mentioned variables (the results variables), and as my variables' names differ only in their first part, I thought of writing a loop function like this:
for idx=1:80
x= Indi_All {idx,1} (1,1)
% idx: is the Individual IDs ... 80 is the total number of individuals
% Indi_All is a cell array containing the basic info, IDs and demographics..
here x will get the initial part of the variables names e.g. 'Mike' or 'Adam'
Indi_Results {idx,1} = x
Indi_Results {idx,2} = prctile (x_Sim_V_software1', (5))
Indi_Results {idx,2} = x_5P_software1'
Indi_Results {idx,3} = prctile (x_Sim_V_software1', (10))
Indi_Results {idx,3} = x_10P_software1'
Indi_Results {idx,4} = prctile (x_Sim_V_software1', (25))
Indi_Results {idx,4} = x_25P_software1'
Indi_Results {idx,5} = prctile (x_Sim_V_software1', [50])
Indi_Results {idx,5} = x_Median_software1'
Indi_Results {idx,6} = prctile (x_Sim_V_software1', (75))
Indi_Results {idx,6} = x_75P_software1'
Indi_Results {idx,7} = prctile (x_Sim_V_software1', (90))
Indi_Results {idx,7} = x_90P_software1'
Indi_Results {idx,8} = prctile (x_Sim_V_software1', [95])
Indi_Results {idx,8} = x_95P_software1'
% the code and calculations go even more and more ...
end
so as the experts can see ... the x will be recognized in the code (right columns) as 'x' and not as I actually want it to mean, namely the variable x which contains a string value like: 'Mike' ..
My question is:
1) Can I solve this? Is there any function to construct the names of the variables from two different strings ?! so maybe something similar to num2str but to add string to string! In other words, to add the changing part 'Mike','Adam', etc. to the unchanging part '_Sim_V_software1' to get a variable which I can use in the loop function?!
I don't know... I have the feeling that my question is silly, but somehow I spent a lot of time for this and it is not working the way I want it to be! hope that this has nothing to do with the fact that my mind already knows something about the weekend going to start :)
I would be glad to hear something from you and thanks a lot in advance ... !