i want to change the size of vector in a loop

here is my code, i m very new to matlab so please help
for a=2*n:-1:1
[a,1]=size(w)
end
i want to extract min value of w each time for that i've to change the vector size every time how can i do that?

1 comentario

Walter Roberson
Walter Roberson el 31 de Jul. de 2011
What do _you_ mean by the minimum of a vector of complex numbers?

Iniciar sesión para comentar.

Respuestas (1)

Oleg Komarov
Oleg Komarov el 31 de Jul. de 2011
You don't have to change any size but you can index the values of w to take the moving minimum:
w = rand(20,1);
n = numel(w)/2;
out = zeros(n,1);
for a = 0:2*n-1
out(a+1) = min(w(1:end-a));
end
The first element of out is the min on the entire array - 2*n -, the next is the first n*2-1 elements and so on.

2 comentarios

Sudhanshu kher
Sudhanshu kher el 31 de Jul. de 2011
sir but my w value is a complex no.
basically its a eigenvalue, so i want that my eigenvectors should arrange themselves according to the order of w
Oleg Komarov
Oleg Komarov el 31 de Jul. de 2011
Then you have to be clear about what you're trying to achieve: http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer

Iniciar sesión para comentar.

Categorías

Más información sobre Elementary Math en Centro de ayuda y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Preguntada:

el 31 de Jul. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by