I have a Nx1 vector of values. What I would like to do is create a NxN matrix where each value represents the difference between the ith and jth value – sort of like a large correlation matrix. I’ve done with this with a loop but I’m looking for a more elegant way to approach using MATLAB’s vectorization capabilities as this vector may get quite large.
Share
what about
which can be definitely improved by doing
?
A little performance check:
result
(Tim’s data check:
diff__ =
).