Error using sym/subsindex () while using the symsum function
Afficher commentaires plus anciens
Y = [-12.5j +12.5j 0 0 0 0 0 0;
+12.5j -16.649j +1.297j +1.815j +1.037j 0 0 0;
0 +1.297j 5.899+2.288j -5.899-5.984j 0 +2.399j 0 0;
0 +1.815j -5.899-5.984j 5.899+2.169j 0 0 +2j 0;
0 +1.037j 0 0 -3.537j 0 0 +2.5j;
0 0 +2.399j 0 0 -2.399j 0 0;
0 0 0 +2j 0 0 0.871-1.505j -0.871-0.495j;
0 0 0 0 +2.5j 0 -0.871-0.495j 0.871-2.005j];
V = [0 1+0.5j 1+0.5j 1+0.5j 1+0.5j 1+0.5j 1+0.5j 1+0.5j];
syms k
f = abs(V(4))*abs(V(k))*abs(Y(4,k))*sin(angle(Y(4,k))-angle(V(4)+V(k)));
E = subs (f, k, 0:7);
Q = sum(E);
I got the error in line(13), in the f equation, i dont know what is the reason for that, i tried several things and it still did not work, so if anyone know what is the problem exactly, and could help me, as i need to finish this as soon as possible
1 commentaire
Salem Almahri
le 24 Nov 2020
Réponse acceptée
Plus de réponses (1)
There are two possible ways in Matlab, that allow a syntax like
V(k)
The first is indexing with a variable like in a for loop:
> V = 5:10
V =
5 6 7 8 9 10
>> k = 3
k =
3
>> V(k)
ans =
7
The second one is using symbolic functions:
>> syms k
>> V(k) = 3*k + 1
V(k) =
3*k + 1
>> V(3)
ans =
10
What you do is mixing both possibilities, which is not allowed. So you have to rethink your code to what you want to do
2 commentaires
Salem Almahri
le 24 Nov 2020
You define
syms k
and then use it to index an array V in the next line - this does not work.
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!