Question
I have A=[1 2; 3 6; 3 5; 1 4; 4 6; 2 7; 1 6; 6 5; 2 3; 6 7; 3 4]; B=[1 2; 1 6; 2 3; 3 4; 4 6];,/pre? I want to find missing element between A and B result should be res=[3 6; 3 5; 1 4; 2 7; 6 5; 6 7] I used this res = A(~all(ismember(A,B),2),:); But it does not give me [3 6; 1 4]
Expert Answer
Prashant Kumar
PhD Expert
Answered Aug 20, 2026
>> A = [1,2;3,6;3,5;1,4;4,6;2,7;1,6;6,5;2,3;6,7;3,4]; >> B = [1,2;1,6;2,3;3,4;4,6]; >> R = setdiff(A,B,'rows') R = 1 4 2 7 3 5 3 6 6 5 6 7
To get the same order, use the 'stable' option or this:
>> [~,X] = setdiff(A,B,'rows'); >> X = sort(X); >> R = A(X,:) R = 3 6 3 5 1 4 2 7 6 5 6 7
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related matlab Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →