Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
Mallouli Marwa
Mallouli Marwa le 3 Mai 2016
Commenté : Andrei Bobrov le 3 Mai 2016
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)

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 3 Mai 2016
Modifié(e) : Andrei Bobrov le 3 Mai 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;
  2 commentaires
Mallouli Marwa
Mallouli Marwa le 3 Mai 2016
Thank's how can i plot mn=f(ii)
Andrei Bobrov
Andrei Bobrov le 3 Mai 2016
plot(ii(:),mn(:))

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by