matrix , rows , selection , help
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Firas
am 22 Mai 2014
Bearbeitet: Sean de Wolski
am 22 Mai 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
0 Kommentare
Akzeptierte Antwort
Sean de Wolski
am 22 Mai 2014
Bearbeitet: Sean de Wolski
am 22 Mai 2014
C = A(ismember(A(:,1:2),B,'rows'),:)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!