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
Oleg Komarov 2012년 5월 9일
Not very clear, so do you want values which are not 600? (greater and less...)
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일

0 개 추천

EDITED
idx = idx = col1(:,1) < 600 & col1(:,1) ~= 0;
col2 = col1(idx, 1);

댓글 수: 4

Richard Brown
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
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
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.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

태그

질문:

2012년 5월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by