Comparing two matrices, as fast as possible
10 views (last 30 days)
I am currently writing a music comparing AI code on MATLAB. It is my graduation project.
Firstly, I printed filtered with grayscale 1,0 spectrogram graph of our saved music with the function i write and i recorded 5 second sound. I also processed same way to the sound I recorded from external mic.
SPECTROGRAM OF MUSIC:
5 SECOND RECORDED FILE:
They are both 129xSamples
How can i compare and search from the exact music matrix as fast as possible? I wrote the little function but i cant use with this way. It took apx 56 second and its too long for one song.
Here my little code:
%Takes data from file
%Deletes .mat part
Music1 = extractBefore(Music1,".");
Sample1 = extractBefore(Sample1,".");
[a,b] = size(M1);
[c,d] = size(S1);
sira = 1;
%Comparing row by row until the finish to findout how long will it take
for SS = 1:b-d+1
count = 0;
for jj = sira:d+(sira-1)
for ii = 1:129
list1(end+1) = CC;
What is the best way to compare two matrices?
I am planning to compare from 100 to 200 music sample as fast as possible. I am open to any recommendations.
Thanks a lot
Shubham Rawat on 16 Mar 2021
I have written a code and I had done intersction of both the matrices column wise without using the for loop.
%transposing the matrices so that number of columns should be same.
a = counting_stars';
b = girenfile';
%intersecting both matrices
[c, ia, ib] = intersect(a, b, 'rows');
c will give the common columns, ia and ib will give all the indices which are common in both a and b.
You may look into this documentation of intersect.
Hope this Helps!