Hello,
It would be a great help if someone could suggest a way to save data from the loop in a matrix. I am using the following code.
p = [1,2,3;4,5,6];for i = 1:3 x = p(1,i); y = p(2,i); u1 = [x*y x/y 2*x]; u2 = [y/x x*y y/2];end
For each iteration of the loop, the values of u1 and u2 will change. Now, I want to store this u1 and u2 values in matrix U, such that at the end of the loop U will be:
U = u1 %from i = 1
u2 %from i = 1 u1 %from i = 2
u2 %from i = 2 u1 %from i = 3
u2 %from i = 3
I have searched through numerous threads on similar topics but haven't found a satisfactory answer. Could someone please help me with this.
Thanking You,
Harshil
Best Answer