Changing variable in a looped code
32 views (last 30 days)
Hi, I have been trying to figure this out for a while. It will help in many cases.
I have a set of variables as such;
x1 = [3 4 5 2 3];
x2 = [4 2 7 8 3];
x3 = [8 2 9 3 9];
y = [1 5 3 8 5];
I would like to write a looped program in which the x variable in use would change in each loop. for example,
I would like the program to use x1 for the first loop and than x2 for the second loop and so on.
I have tried writing xi but that does not work.
More Answers (2)
rifat on 3 Sep 2013
string=['plot(x' num2str(i) ',y);'];
I think this will do