syntax error for matrix

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);

Answers (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)
I = 
.

5 Comments

That was fast. Thank you. That got rid of the syntax error but it isn't giving me any output. You know any reason that would happen?
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)
I = 
However I’m not certain that provides much additional clarity.
This is the best I can do.
.
My output shows the file name and then gives me nothing else? I didn't use the simplify command or the sympref line either.
It works with simplify, so thanks again. But how do you get the output look so nice?
I =
(V*(20*s^3 + 50*s^2 + 19*s + 2))/(24*s^4 + 172*s^3 + 184*s^2 + 89*s + 14)
(V*(4*s^3 + 26*s^2 + 13*s + 2))/(24*s^4 + 172*s^3 + 184*s^2 + 89*s + 14)
(2*V*s*(2*s^2 + 25*s + 6))/(24*s^4 + 172*s^3 + 184*s^2 + 89*s + 14)
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.

Sign in to comment.

Products

Release

R2021b

Asked:

on 6 Dec 2021

Commented:

on 6 Dec 2021

Community Treasure Hunt

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

Start Hunting!