Pearsons correlation using corrcoef not working
Ältere Kommentare anzeigen
I am trying to calculate the pearsons correlation between two variables in a timetable. I am utalising the corrcoef() function. However the output it gives me is always NaN NaN NaN NaN. Why is this? How can I fix this?
4 Kommentare
Daniel Pollard
am 24 Mär. 2021
Elizabeth Lees
am 24 Mär. 2021
William Rose
am 24 Mär. 2021
Are the variables (vectors) which you are trying to correlate both numbers (not strings or times or dates), with the same length?
If you provide the timetable, and the code that does not work, as attached files, it will help others help you. An example of corrcoeff() operating on two columns from a table is below.
>> height=1.7+0.2*randn(10,1);
>> weight=70+10*randn(10,1);
>> T=table(height,weight);
>> corrcoef(T.height,T.weight)
ans =
1.0000 0.2262
0.2262 1.0000
Elizabeth Lees
am 24 Mär. 2021
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Descriptive Statistics and Insights finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!