for loop in matlab
7 views (last 30 days)
plz dont refer me to any link.i have a code for for loop.kindly explain it line by line if possibe.
m = 1;
for n = 1:length(sol.xs)
possibleSol(1,m) = double(sol.xs(n));
possibleSol(2,m) = double(sol.ys(n));
possibleSol(3,m) = double(sol.zs(n))
Cris LaPierre on 18 Nov 2020
Edited: Cris LaPierre on 18 Nov 2020
The values are changing because the indexing inside the for loop is telling it where to place the values.
I'm going to direct you to an interactive tutorial so you can learn and get some practice with the concept. See Ch 5 of MATLAB Onramp. If you need a little more explanation and practice with for loops, check out Ch 13.3 as well.