How can i display a vector as a result of a for loop ?

조회 수: 2 (최근 30일)
Mallouli Marwa
Mallouli Marwa 2016년 5월 3일
댓글: Andrei Bobrov 2016년 5월 3일
I have this for loop and i want to display the vector of mn. But this program display me only the last value of mn :
for i=0:200:50000
v= -i.*x(:,3);
mn= (max(v)-min(v))./2
end
disp(mn)

채택된 답변

Andrei Bobrov
Andrei Bobrov 2016년 5월 3일
편집: Andrei Bobrov 2016년 5월 3일
ii=0:200:50000;
n = numel(ii);
mn = zeros(n,1);
for jj = 1:n
v = -ii(jj).*x(:,3);
mn(jj) = (max(v)-min(v))./2 ;
end
or without for..end loop
v = x(:,3)*(0:200:50000);
mn = (max(v) - min(v))/2;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by