Question
(MATLAB) I have a 943x1682 matrix in which I want to calculate the two most similar vectors in this matrix. So i want see the
(MATLAB)
I have a 943x1682 matrix in which I want to calculate the two most similar vectors in this matrix. So i want see the co-sine distance of each vector in the matrix to each vector in the matrix, of course not including the vector with itself, if oen cannot do that I can just ignore those.
for i=1:n
for j=1:n
cosSimalll(i,j)=dot(A(:,i),A(:,j))/(norm(A(:,i)*norm(A(:,j))));
end
end
I made this loop to try to calcualte this, so I can get a 1682x1682 matrix, with each cell corresponding to the similarity between i and j. However when I run this, it takes forever to run, and when I try to ope nthe resulting matrix in my workspace, it says Cannot display summaries of variables with more than 524288 elements.
Is there an easier way to do this or am i doing something wrong? Please get back to me asap. Thank you!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started