I just wrote a kinda-foreach loop in Matlab and came across this weird behavior:
I have a matrix A:
A = [ 3 9 5 0];
And I want to use the foreach (as described here ) on A.
If I write this:
for i = A disp('for') i end
The result will be:
for i = 3 9 5 0
But when I use transpose, the result will change:
for i = A' disp('for') i end
Result:
for i = 3 for i = 9 for i = 5 for i = 0
What result do I want.
Can someone explain what is going on here? What is the difference between the two cases?
for-loop matlab
Mahm00d
source share