MATLAB Answers

Summing data columns in a series

1 view (last 30 days)
jacob Mitch
jacob Mitch on 31 Oct 2019
Commented: jacob Mitch on 1 Nov 2019
If I have a 2 data columns and I want to raise them to the power of K and sum the using sigma notation from k=1 to 10 how would I do that. So far I have tried.
Datacolumn1; %defined variables
Datacolumn2;
f=0;
for k=1:10
Data=(Datacolumn1.^k-Datacolumn2.^k).^2; %I want datacolumn1.^k minus datacolumn2.^k all squared summed(sigma notation) from k=1:10
f=f+Data
end
Have I entered that correctly. Any help would be appreciated.

  0 Comments

Sign in to comment.

Answers (1)

KALYAN ACHARJYA
KALYAN ACHARJYA on 31 Oct 2019
Edited: KALYAN ACHARJYA on 31 Oct 2019
I want to raise them to the power of K and sum the using sigma notation from k=1 to 10
k=?? % define
Data=Datacolumn1.^k+Datacolumn2.^k;
result=sum(Data(1:10));
If your code is correct? then
k=?? % define
Data=(Datacolumn1.^k-Datacolumn2.^k).^2;
result=sum(Data(1:10));

  3 Comments

jacob Mitch
jacob Mitch on 31 Oct 2019
Hi thanks the question is written as Sigma(K=1 on the bottom to 10 on top) (Datacolumn1^k-Datacolumn2^k) ^2
KALYAN ACHARJYA
KALYAN ACHARJYA on 31 Oct 2019
Is this?
k=?? % define
Data=(Datacolumn1.^k-Datacolumn2.^k).^2;
result=sum(Data(end-9:end));
jacob Mitch
jacob Mitch on 1 Nov 2019
Hi there would I not need a for loop as k starts at 1 and goes to 10 for sigma. I think its just the root mean square error with k powering the vectors.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by