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;
  2 件のコメント
Mallouli Marwa
Mallouli Marwa 2016 年 5 月 3 日
Thank's how can i plot mn=f(ii)
Andrei Bobrov
Andrei Bobrov 2016 年 5 月 3 日
plot(ii(:),mn(:))

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by