필터 지우기
필터 지우기

a problem with conditions and deleting rows

조회 수: 4 (최근 30일)
Jules Ray
Jules Ray 2012년 5월 4일
dear all, this is maybe a simple question but i can not find the way to solve it... may be you can help me...
i got a 1x4 (double) matrix named codename_station
codename_station=
77 79 90 79
i have also a big matrix named tab, composed by 6 columns and many rows, tab is also double
tab=
67 66 81 67 95.5400000000000 0.630000000000000
80 85 72 69 31.9400000000000 0.990000000000000
77 79 90 79 230.930000000000 2.59000000000000
80 73 67 72 6.09000000000000 1.90000000000000
84 69 84 65 12.1700000000000 0.570000000000000
84 69 84 65 60.3900000000000 0.520000000000000
67 79 78 84 438.610000000000 0.970000000000000
77 79 90 79 74.6700000000000 1.02000000000000
as you see the first four columns represent the coded name (double('string')), where the string is composed by four letters like CBQC or CONT etc....
how ever, i need to create a code to create a new table only with the rows the table tab, that coincide with the codename_station columns....
i mean, i need a new table called tab2 (for example) with this data
tab2=
77 79 90 79 230.930000000000 2.59000000000000
77 79 90 79 74.6700000000000 1.02000000000000
as you see the first four rows concede with the four rows of codename_station
i have been trying with this code:
if tab(:,(1:4))~=codename_station(1,(1:4));
tab(:,:)=[];
end
but gives me an error that says
Error using ~=
Matrix dimensions must agree.

채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 5월 4일
out = tab(ismember(tab(:,1:4),codename_station,'rows'),:)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by