Deleting rows in Matlab
Mostrar comentarios más antiguos
I have a large column vector (col1) I have the following code:
notcontacts=(col1(:,1)>600);
col1=col1.*notcontacts
Now I want to to delete all of the zeros that are in the column of data so i have the following (col2) which is only made up of the values that are greater than less than 600.
3 comentarios
Oleg Komarov
el 9 de Mayo de 2012
Not very clear, so do you want values which are not 600? (greater and less...)
charles atlas
el 9 de Mayo de 2012
charles atlas
el 9 de Mayo de 2012
Respuestas (1)
Oleg Komarov
el 9 de Mayo de 2012
EDITED
idx = idx = col1(:,1) < 600 & col1(:,1) ~= 0;
col2 = col1(idx, 1);
4 comentarios
Richard Brown
el 9 de Mayo de 2012
urgh, this question illustrates how bad this code font is! we can't tell the difference between col1, co11, and coll!
Geoff
el 10 de Mayo de 2012
That's odd... It renders okay in Firefox on Windows. Using some kind of courier-based font. But I'm sitting rather close to a biggish screen.
Geoff
el 10 de Mayo de 2012
@Oleg : You forgot the removal of zeros:
idx = col1(:,1) < 600 & col1(:,1) ~= 0;
Oleg Komarov
el 10 de Mayo de 2012
Thanks Geoff, amended.
Categorías
Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!