how to calculate the correlation coefficient of two vectors using 'symsum' function

1 view (last 30 days)
i am trying to calculate the correlation coefficient of two vectors and put using the symsum function:
C(j,k)= N*symsum(j1(i)*j2(i),i,1,N)-symsum(j1(i),i,1,N)
where j1 and j2 are the two vectors I am getting the following error:
Error using sym/subsindex (line 1558)
Indexing input must be numeric, logical or ':'.
I hope you can help me fix this problem thanks in advance

Answers (1)

John D'Errico
John D'Errico on 8 Feb 2016
Edited: John D'Errico on 8 Feb 2016
You misunderstand the purpose and use of symsum. You have vectors. They are not symbolic. They are just numbers. Just use sum instead. As for your use of i there, you cannot simply make up syntax. It looks like you are trying to create an implicit loop of some sort, and hoping that symsum can figure out what you want to do.
  1 Comment
RB
RB on 17 May 2017
@ John
Can you please have a look at this question. https://uk.mathworks.com/matlabcentral/answers/340753-error-using-sym-subsindex-line-737
Thanks.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!