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

답변 (1개)

Star Strider
Star Strider 2021년 12월 6일

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

Thomas O'Reilly
Thomas O'Reilly 2021년 12월 6일
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.
.
Thomas O'Reilly
Thomas O'Reilly 2021년 12월 6일
My output shows the file name and then gives me nothing else? I didn't use the simplify command or the sympref line either.
Thomas O'Reilly
Thomas O'Reilly 2021년 12월 6일
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)
Star Strider
Star Strider 2021년 12월 6일
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.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

릴리스

R2021b

태그

질문:

2021년 12월 6일

댓글:

2021년 12월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by