Deleting rows in Matlab
显示 更早的评论
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 个评论
Oleg Komarov
2012-5-9
Not very clear, so do you want values which are not 600? (greater and less...)
charles atlas
2012-5-9
charles atlas
2012-5-9
回答(1 个)
Oleg Komarov
2012-5-9
EDITED
idx = idx = col1(:,1) < 600 & col1(:,1) ~= 0;
col2 = col1(idx, 1);
4 个评论
Richard Brown
2012-5-9
urgh, this question illustrates how bad this code font is! we can't tell the difference between col1, co11, and coll!
Geoff
2012-5-10
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
2012-5-10
@Oleg : You forgot the removal of zeros:
idx = col1(:,1) < 600 & col1(:,1) ~= 0;
Oleg Komarov
2012-5-10
Thanks Geoff, amended.
类别
在 帮助中心 和 File Exchange 中查找有关 Whos 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!