Effacer les filtres
Effacer les filtres

how to write a correlation coefficient code with only the use of SUM function.

1 vue (au cours des 30 derniers jours)
alexander fastiggi
alexander fastiggi le 1 Nov 2019
how to write a correlation coefficient code with only the use of SUM function.
YES, you can not just use
corrcoef(x,y)
mean(x) mean(y)
std(x) std(y)
to write this code.
literally writing a function to find correlation coefficient with SUM as the only intrinsic function

Réponses (1)

Walter Roberson
Walter Roberson le 1 Nov 2019
That is not possible. The Pearson Correlation Coefficient cannot be calculated without multiplications or divisions.
Notice the use of . That is defined as which is something that cannot be calculated without at least one division.
  2 commentaires
alexander fastiggi
alexander fastiggi le 1 Nov 2019
I never said you can't multiply or divide.
Walter Roberson
Walter Roberson le 1 Nov 2019
Yes you did!! I quote,
with only the use of SUM function
In MATLAB, multiplication and division are functions. The .* operator is formally known as times and the ./ operator is formally known as rdivide . .* and ./ are "syntax sugar" .
A .* B
is exactly the same as times(A, B) -- a function call.
In MATLAB, neverly everything is a function. Subscripting is a function. Assignment is the function whose formal name is subsasgn() .
These are the only things in MATLAB that are not functions:
>> iskeyword
ans =
20×1 cell array
{'break' }
{'case' }
{'catch' }
{'classdef' }
{'continue' }
{'else' }
{'elseif' }
{'end' }
{'for' }
{'function' }
{'global' }
{'if' }
{'otherwise' }
{'parfor' }
{'persistent'}
{'return' }
{'spmd' }
{'switch' }
{'try' }
{'while' }

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by