extracting data from matrix

Hello every bod
let assume matrix
A =
[10 20 1
30 40 2
50 60 3
70 80 4
90 100 5]
B =
[30 40
70 80]
we need to identify the third column of the matrix B, hence
B =
[30 40 2
70 80 4]

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 7 月 16 日
編集済み: Azzi Abdelmalek 2016 年 7 月 16 日

1 投票

A= [10 20 1
30 40 2
50 60 3
70 80 4
90 100 5]
B=[30 40
70 80]
idx=ismember(A(:,1:2),B,'rows')
B(:,3)=A(idx,3)

2 件のコメント

Abdelwahab Fawzy
Abdelwahab Fawzy 2016 年 7 月 16 日
I tried this code for other different matrices I get a problem at which the third column is not compatible with the first and 2'nd column data in terms of ordering
Azzi Abdelmalek
Azzi Abdelmalek 2016 年 7 月 16 日
編集済み: Azzi Abdelmalek 2016 年 7 月 16 日
Can you explain? post an example to make your question clear

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

質問済み:

2016 年 7 月 16 日

編集済み:

2016 年 7 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by