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.
Ältere Kommentare anzeigen
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
Use concatenation ?
%Initialisation
l = [];
% Calculation and concatenation
for i=1:4
for j=1:5
new_value = ... ;
l = [l new_value];
end
end
Or initialise an array yourself :
%Initialisation
l = zeros(1, 4*5);
% Calculation
for i=1:4
for j=1:5
new_value = ... ;
l(5*(i-1)+j) = new_value;
end
end
Walter Roberson
am 26 Aug. 2015
g is going to be a scalar. What is the point of using max() on the scalar?
kaavya subramani
am 26 Aug. 2015
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Convert Image Type finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!