Sigma notation with matrices
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Anna Singley
am 12 Jul. 2019
Kommentiert: Star Strider
am 13 Jul. 2019
I am trying to model a differential equation including
, where C is a 4 by 4 matrix, i are rows, and j are vectors. The sigma notation is crucial towards using the interaction coefficient
with the proper elements in the matrix. I don't at all know what I'm doing, and have been using symsum so far but have gotten absolutely nowhere. How do I code this without getting "Subscript indices must either be real positive integers or logicals errors"?
0 Kommentare
Akzeptierte Antwort
Star Strider
am 13 Jul. 2019
Taking a wild guess:
x = rand(1,4); % Create Vector
C = rand(4); % Create Matrix
for i = 1:4
for j = 1:4
E(i,j) = C(i,j)*x(i)*x(j); % Multiplications
end
end
S = sum(E(:)); % Summation
There are likely more efficient ways to do this, however I am choosing to keep this as transparent as possible. Note that symsum is not intended to do this type of summation.
2 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!