matrix , rows , selection , help

2 views (last 30 days)
Firas
Firas on 22 May 2014
Edited: Sean de Wolski on 22 May 2014
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

Accepted Answer

Sean de Wolski
Sean de Wolski on 22 May 2014
Edited: Sean de Wolski on 22 May 2014
C = A(ismember(A(:,1:2),B,'rows'),:)

More Answers (0)

Categories

Find more on Data Types in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!