I am a newbie. I have problem. I have 20 (1x100) different named vectors. I want to combine these vectors to create a 20x100 matrix with a for loop. There are the examples of vectors.
namelist=["First","B","New"]
First = [1:100]
B = [1:2:200]
New = [4:4:400]
for i = 1: length(namelist)
new_database(i,1:end) = namelist{i}
end
But, when I want to try this I saw "The end operator must be used within an array index expression." error. I know I can do same thing with this: "new_database= [First;B;New]"
but i want to do this with a for loop. Would you help me how can fix this error? or Would you explain me how can do this?
new_database(i,:) = eval([namelist{i}, ';']);
. What you should do is avoid dynamic variable naming and not put yourself in a position where this is required in the first place! Please see MathWorks: Evading Eval – Wolfie