Deleting rows in Matlab

1 次查看(过去 30 天)
charles atlas
charles atlas 2012-5-9
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 个评论
charles atlas
charles atlas 2012-5-9
I am sorry, typo... I want a column (col2) of numbers that are less than 600. Ex:
col1=[0 0 456 245]
then after column manipulation I want:
col2=[456 245]
charles atlas
charles atlas 2012-5-9
I meant to say less than 600 not "greater than less than"

请先登录,再进行评论。

回答(1 个)

Oleg Komarov
Oleg Komarov 2012-5-9
EDITED
idx = idx = col1(:,1) < 600 & col1(:,1) ~= 0;
col2 = col1(idx, 1);
  4 个评论
Geoff
Geoff 2012-5-10
@Oleg : You forgot the removal of zeros:
idx = col1(:,1) < 600 & col1(:,1) ~= 0;
Oleg Komarov
Oleg Komarov 2012-5-10
Thanks Geoff, amended.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by