MATLAB: How to link loops together

forloops

I am trying to make a program to get this numbers
0 1 0
0 0.8 0.2
0 0.6 0.4
0 0.4 0.6
0 0.2 0.8
0 0 1
0.1 0.9 0
0.1 0.7 0.2
0.1 0.5 0.4
0.1 0.3 0.6
0.1 0.1 0.8
0.1 0 0.9
and so on but I cant make the program to reduce the values of the second and third column when the first column increases.
This is my code.
Thanks
lai=0:0.1:1;
laj=1:-0.2:0;
lat=0:0.2:1;
for i=1,length(lai)
for j=1,i
for t=1,j
j
lam1(1,:)=lai;
lam2(1,:)=laj;
lam3(1,:)=lat;
end
end
end

Best Answer

The syntax for "for" loops is
for j=1:i
not
for j=1,i
The line you entered does have meaning: in particular it is the same as
for j = [1]
i
which is to say that it would set j to 1 and then print out the value of i, and then after the rest of the statements in the body executed once the loop would be finished
Related Question