matrix , rows , selection , help

10 ビュー (過去 30 日間)
Firas
Firas 2014 年 5 月 22 日
編集済み: Sean de Wolski 2014 年 5 月 22 日
hi !! How from A and B we can found matrix C ¸; This is the big question I write a script but it does not work please help me , thanks ------------------------------------------------------------------------------------------ close all clear all clc A=[3,5,0;2,4,7;8,5,0;514,2
<<
>>
,21;888,5,11;3,5,0;2,4,7;8,5,0;514,2,21;8,15,111] B=[8,15;54,12;888,5;8,5] A_initial=A; B_initial= B; A=sortrows(A) B=sortrows(B) %B(:,end)=[]; nA=length(A(:,1)); nB=length(B(:,1)); Longueur_ligne=length(A(1,:)) PP=9999999*ones(nB,1); k=1; for i=1:1:nA for j=1:1:nB ligne_A=[A(i,1) A(i,2)]; ligne_B=[B(j,1) B(j,2)]; if ligne_A==ligne_B PP(k)=A(i,Longueur_ligne); k=k+1; end end i; j; end

採用された回答

Sean de Wolski
Sean de Wolski 2014 年 5 月 22 日
編集済み: Sean de Wolski 2014 年 5 月 22 日
C = A(ismember(A(:,1:2),B,'rows'),:)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by