Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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)

Risposta accettata

Andrei Bobrov
Andrei Bobrov il 3 Mag 2016
Modificato: Andrei Bobrov il 3 Mag 2016
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;

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by