Borrar filtros
Borrar filtros

add and remove columns from a marix

1 visualización (últimos 30 días)
Niki
Niki el 6 de Sept. de 2011
I am writing a code , in fact I have a matrix and I select the fist column then I add next column and in each epoch one column will be adding to the previous for example first 1 , the second epoch 1 and 2 , the third epoch 1, 2 and 3 and so on .
I do that like this
for i = 1:size(Matrix,2) new matrix after each iteration = Matrix(:,1:i);
but now before i put end, I would like to evaluate this new matrix.
I would like to say if nnn> 0.5 then keep this and continue the loop otherwise remove this column from the Matrix and go for the next one and continue the loop
Do you have any idea?

Respuestas (1)

Fangjun Jiang
Fangjun Jiang el 6 de Sept. de 2011
n=rand(5,1);
Matrix=magic(5);
NewMatrix=[];
for k=1:size(Matrix,2)
if n(k)>0.5
NewMatrix(:,end+1)=Matrix(:,k);
end
end
  12 comentarios
Fangjun Jiang
Fangjun Jiang el 7 de Sept. de 2011
Sorry, I won't do it. It seems to be a different topic. Ask a different question and someone with statistics expertise might be able to help you.
Niki
Niki el 7 de Sept. de 2011
Thanks Fangiun

Iniciar sesión para comentar.

Categorías

Más información sobre Variables en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by