create a new matrices by using existing matrices

1 回表示 (過去 30 日間)
tevzia
tevzia 2013 年 11 月 13 日
回答済み: Vivek Selvam 2013 年 11 月 13 日
Hi,
I try to create a new matrices by using specific condition from existing matrices(its a data file) for example I have
a= [1,2,10;
1, 3, 20;
1, 4, 5;
1, 5, 7;
2, 3, 3;
2, 4, 1;
2, 5, 3;
3, 4, 6;
3, 5, 4;
4, 5, 8];
(first and second column are points and third one is the distance of each other) I want point number 2, 3 and 4 in the new matrices (those numbers (x) are come from another matrices(y) which are index of zeros)
x=find(y==0);
result supposed to be (just those numbers, not all of them)
b=[2,3,3;
2,4,1;
3,4,6];
not like this
b=[2,3,3;
2,4,1;
2,5,3;
3,4,6
3,5,4];
I am sorry if i cant explain well or it seems like do for me. I appreciate for some tip

採用された回答

Vivek Selvam
Vivek Selvam 2013 年 11 月 13 日
Hope this helps.
x = a(:,1)
y = a(:,2)
want = [2 3 4]
choose = ismember(x,want) & ismember(y,want)
a(choose,:,:)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by