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 次查看(过去 30 天)
显示 更早的评论
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 个评论
Walter Roberson
2015-8-26
g is going to be a scalar. What is the point of using max() on the scalar?
采纳的回答
Walter Roberson
2015-8-27
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!