canlab / MediationToolbox

Single-level and multi-level mediation analyses for any kind of data, with bootstrap-based significance testing. Neuroimaging-oriented functions allow for mediation effect parametric mapping (mapping of mediation effects across the brain) and multivariate mediation.
https://canlabweb.colorado.edu/wiki/doku.php/help/mediation/m3_mediation_fmri_toolbox
83 stars 29 forks source link

Function(vecnorm) name conflict #9

Closed SuhwanGim closed 1 year ago

SuhwanGim commented 4 years ago

Hi, I got error message when I ran the function corr wiht multiple columns ( e.g., corr(randn(50,2), randn(50,4)) ) in MATLAB after 2018b version.

error message here:

Error using bsxfun Non-singleton dimensions of the two input arrays must match each other.

Error in corr>corrPearson (line 307) coef = bsxfun(@rdivide,coef,dx'); coef = bsxfun(@rdivide,coef,dy); % coef = coef ./ dx'*dy;

I think it is due to the same function name vecnorm . After MATLAB 2018 version, they made built-in function MATLAB/vecnorm , and they start to implement 'vecnorm' in 'corr' .

From line 303 in corr>corrPearson

    y = bsxfun(@minus,y,sum(y,1)/n);  % Remove mean
    coef = x' * y; % 1/(n-1) doesn't matter, renormalizing anyway
    dx = vecnorm(x,2,1);
    dy = vecnorm(y,2,1);
    coef = bsxfun(@rdivide,coef,dx'); coef = bsxfun(@rdivide,coef,dy); % coef = coef ./ dx'*dy;

So, I think 'vecnorm' in this toolbox will change the name for potential conflicts.

Thanks. Suhwan Gim