Hi i attached simple code,i need to store every result from for loop on each iteration,please see my code and alter it sir.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
kaavya subramani
am 26 Aug. 2015
Beantwortet: Walter Roberson
am 27 Aug. 2015
t=[1 2 3 4 5];
for i=1:4
for j=1:5
g=i+j;
l=max(g); %Here i need to save l value in one array,likewise save l value for all iteration
end
end
3 Kommentare
Walter Roberson
am 26 Aug. 2015
g is going to be a scalar. What is the point of using max() on the scalar?
Akzeptierte Antwort
Walter Roberson
am 27 Aug. 2015
nt = length(t);
for i = 1:4
g = zeros(nt,1);
for j = 1:nt
g(j) = i + t(j);
end
l(i) = max(g);
end
or more simply
for i = 1 : 4
g = i + t;
l(i) = max(g);
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!