syntax error for matrix
Afficher commentaires plus anciens
I get the error on the first open bracket, here's the code.
close all; clear all;
syms s V;
A = [3+2+1*s 1*s+2 -3; -s-2 2+1*s+2*s+4*s -2*s; -3 -2*s 3+(1/(2*s))+2s];
B = [V;0;0];
[I]=linsolve(A,B);
Réponses (1)
Typo:
A = [3+2+1*s 1*s+2 -3; -s-2 2+1*s+2*s+4*s -2*s; -3 -2*s 3+(1/(2*s))+2s]
↑ ← MISSING MULTIPLICATION OPERATOR
Correct that, and it runs without error —
syms s V
sympref('AbbreviateOutput',false);
A = [3+2+1*s 1*s+2 -3; -s-2 2+1*s+2*s+4*s -2*s; -3 -2*s 3+(1/(2*s))+2*s];
B = [V;0;0];
[I]=linsolve(A,B)
.
5 commentaires
Thomas O'Reilly
le 6 Déc 2021
My pleasure!
It gives me output (as demonstrated), so I guess that depends on the definition of ‘output’.
Numeric output would require that the functions be evaluated at one (or more) values of the Laplace variable s with specific values of V, although that may be variable as well (for example an A-C voltage source, although that could be modeled by a Laplace transform as well).
Simplifying them may provide some benefit —
syms s V
sympref('AbbreviateOutput',false);
A = [3+2+1*s 1*s+2 -3; -s-2 2+1*s+2*s+4*s -2*s; -3 -2*s 3+(1/(2*s))+2*s];
B = [V;0;0];
[I]=simplify(linsolve(A,B), 500)
However I’m not certain that provides much additional clarity.
This is the best I can do.
.
Thomas O'Reilly
le 6 Déc 2021
Thomas O'Reilly
le 6 Déc 2021
Star Strider
le 6 Déc 2021
The typeset (LaTeX) output is the default here with the online Run feature. The same is also possible using the Live Editor (that I use occasionally), or by using the latex function and then a LaTeX interpreter. See The (Not So) Short Introduction to LaTeX2e - lshort.pdf for more details on LaTeX.
Catégories
En savoir plus sur Conversion Between Symbolic and Numeric 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!

