What is the Fastest manner to match rows of 2 matrices?

O
Ottosaul · Dec 24, 2020 · 2K views
Question
I have 2 large matrices (S1, S2) with matching rows I used    [~,index_A,index_B] = intersect( S1',S2', 'rows'); But it is very time consuming. Is there a faster way to do this?
Expert Answer
Profile picture of John Michell
John Michell PhD Expert
Answered Sep 3, 2026

No, not unless, possibly, the columns of S1 and S2 are sorted in some way or have some additional structural properties.

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

Get a Free Consultation or a Sample Assignment Review!