matrix , rows , selection , help
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Firas
le 22 Mai 2014
Modifié(e) : Sean de Wolski
le 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 commentaires
Réponse acceptée
Sean de Wolski
le 22 Mai 2014
Modifié(e) : Sean de Wolski
le 22 Mai 2014
C = A(ismember(A(:,1:2),B,'rows'),:)
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!