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에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!