matrix , rows , selection , help
조회 수: 10 (최근 30일)
이전 댓글 표시
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
채택된 답변
Sean de Wolski
2014년 5월 22일
편집: Sean de Wolski
2014년 5월 22일
C = A(ismember(A(:,1:2),B,'rows'),:)
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!