File Exchange

image thumbnail

prcorr2 - 10 times faster correlation coef.

version 1.0 (33.5 KB) by

Compute correlation coefficient over all dimensions.

9 Downloads

Updated

View License

This is a faster implementation of MATLAB's corr2. Implemented as a mex-file generated with the ITERATOR tool that can be downloaded from www.mathworks.com

Re compile the source with MEX -O prcorr2.c
     
C = PRCORR2(A,B) computes the correlation between A and B. A and B are arrays witn any number of dims but with same number of elements
  
     Class Support
     -------------
     A and B can be any numeric type but not complex value. C is a scalar double.
  
     See also CORR2, CORRCOEF, STD2, ITERATOR, MEX

In future I may complement this fast function with a set of them that can replace some slow MATLAB functions.
 
     (C) 2003 Peter Rydesäter, http://www.rydesater.com

Comments and Ratings (6)

Jakob

Jakob (view profile)

Fantastic! In my analyses ~38 times faster. Thanks for sharing this!

Jin

Jin (view profile)

I also get NaNs. Is there something wrong with mac system?

Yong Du

Really fast! I like it very much.

Bernard Schenk

Define two 2x2 matrix of ones.
Try prcorrel2 --> result is NaN
Correlation should be one, or am I wrong?
That's why I give the N/A rating, just like the function ...

SeungSchik Yoo

Very good code... with my real-life experience on imaging processing, it is about 3 times as fast as corrcoef.m and 50% faster than corr2.m

mani thomas

very useful

MATLAB Release
MATLAB 6.5 (R13)
Acknowledgements

Inspired by: TCP/UDP/IP Toolbox 2.0.6

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

fastop/