Hello, I want to convert summation of below problem into matlab code

1 view (last 30 days)
This is the expanded value of H33
H33=[(U(1,3)*U(1,3))]./[(w(1,1).^2-w.^2)]+[(U(2,3)*U(2,3))]./[(w(2,2).^2-w.^2)]+[(U(3,3)*U(3,3))]./[(w(3,3).^2-w.^2)]+[(U(4,3)*U(4,3))]./[(w(4,4).^2-w.^2)]+[(U(5,3)*U(5,3))]./[(w(5,5).^2-w.^2)]+[(U(6,3)*U(6,3))]./[(w(6,6).^2-w.^2)];
H34=[(U(1,3)*U(1,4))]./[(w(1,1).^2-w.^2)]+[(U(2,3)*U(2,4))]./[(w(2,2).^2-w.^2)]+[(U(3,3)*U(3,4))]./[(w(3,3).^2-w.^2)]+[(U(4,3)*U(4,4))]./[(w(4,4).^2-w.^2)]+[(U(5,3)*U(5,4))]./[(w(5,5).^2-w.^2)]+[(U(6,3)*U(6,4))]./[(w(6,6).^2-w.^2)];
H35=[(U(1,5)*U(1,3))]./[(w(1,1).^2-w.^2)]+[(U(2,5)*U(2,3))]./[(w(2,2).^2-w.^2)]+[(U(3,5)*U(3,3))]./[(w(3,3).^2-w.^2)]+[(U(4,5)*U(4,3))]./[(w(4,4).^2-w.^2)]+[(U(5,5)*U(5,3))]./[(w(5,5).^2-w.^2)]+[(U(6,5)*U(6,3))]./[(w(6,6).^2-w.^2)];
I tried writing it as
S1=0;
for r=(1:6)
S1=S1+[sum(U(r,3)*U(r,3))]/[sum(w(1,r).^2-w.^2)];
end
S2=0;
for r=(1:6)
S2=S2+[sum(U(r,3)*U(r,4))]/[sum(w(1,r).^2-w.^2)];
end
S3=0;
for r=(1:6)
S3=S3+[sum(U(r,5)*U(r,3))]/[sum(w(1,r).^2-w.^2)];
end
z2=S1+(ay3*S2)-(ax3*S3);
Is this correct?
  2 Comments
dpb
dpb on 29 Aug 2019
Edited: dpb on 29 Aug 2019
Dunno...breaks my eyes to try to look at. Do you get same answers?

Sign in to comment.

Answers (1)

Sai Sri Pathuri
Sai Sri Pathuri on 3 Sep 2019
Edited: Sai Sri Pathuri on 3 Sep 2019
There is no need of summation in the expressions of S1, S2 and S3. Try using the following equations.
S1=S1+[U(r,3)*U(r,3)]./[w(r,r).^2-w.^2];
S2=S2+[U(r,3)*U(r,4)]./[w(r,r).^2-w.^2];
S3=S3+[U(r,3)*U(r,5)]./[w(r,r).^2-w.^2];

Categories

Find more on Mathematics in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!