MATLAB Answers

0

Right correlation formula to use

Asked by Carlotta Fabris on 16 Mar 2019 at 11:20
Latest activity Commented on by Image Analyst
on 17 Mar 2019 at 17:57
Hi!
I have a 12x1 vector, and a value. I would like to find the correlation of each of the vector values with my variable. How can I do it?
I tried with corr, corrcoef, corr2 and I only got NaN, why is that?
To clarify my vector is
x = [0.0000827
0.000229
0.000358
0.000486
0.000561
0.000564
0.00483
133
167
178
213
386
];
and my value is y = 2.261133333.
Any suggestions?
Thank you,
Carlotta.

  9 Comments

Maybe you just want the differences between y and x:
% Define DV "peak values":
x = [0.0000827
0.000229
0.000358
0.000486
0.000561
0.000564
0.00483
133
167
178
213
386
];
% and my value is
y = 2.261133333;
indexes = 1 : length(x);
plot(indexes, x, 'b*-', 'LineWidth', 2);
hold on;
plot(indexes, y*ones(1, length(x)), 'r*-', 'LineWidth', 2);
grid on;
% Compute absolute differences
absDiffs = abs(x - y)
% Compute average of those
meanAbsDiff = mean(absDiffs)
0001 Screenshot.png
absDiffs =
2.261050633
2.260904333
2.260775333
2.260647333
2.260572333
2.260569333
2.256303333
130.738866667
164.738866667
175.738866667
210.738866667
383.738866667
meanAbsDiff =
90.1262629971667
Thank you for your suggestion! I will consider this, but what if I don't do the mean of my DVs? What could I do having the peaks and 250 DVs each one having 23 values between 1 and 4?
I hope I was clear, if not, ask me!
It is not clear. I'm not sure what DV is. Are the DV values the values in x? But x has only 12 continuous values, not 250. And only the fractional part seemed to be quantized into levels. And the value of x are not between 1 and 4. Please attach your data.
And I agree with the others in that it does not make sense to correlate a single value against a set of many other values - you can only correlate one set with another. Make another shot at trying to clearly explain things.

Sign in to comment.

0 Answers