While typing the following I get this error:
  • error using symengine
  • matrix must be square
A= [(2.*s +2) - (2.*s + 1) -1 -(2.*s +1)*(9.*s +1) -4.*s -1 -4.*s*(4.*s +1 +1./s)];
>> B= [I1;I2;I3];
>> C=[V;0;0];
>> B= inv(A).*C;
Error using symengine
Matrix must be square.
Where does the error comes from and how can I solve it?

댓글 수: 4

Ameer Hamza
Ameer Hamza 2020년 9월 10일
편집: Ameer Hamza 2020년 9월 10일
A is 1x6 matrix. What do you expect the output of inv(A) to be?
A= [(2*s +2) - (2*s + 1) -1 -(2*s +1) (9*s +1) -4*s -1 -4*s*(4*s +1 +1.s)];
At first when I typed this I had the following as error:
Error: Invalid expression. When calling a function or indexing a variable, use
parentheses. Otherwise, check for mismatched delimiters.
So it is from here that I got into more trouble
Can you share the mathematical form of the equation you are trying to solve?

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

 채택된 답변

Star Strider
Star Strider 2020년 9월 10일
편집: Star Strider 2020년 9월 10일

0 개 추천

MATLAB will not automatically parse ‘A’ into separate elements. It is necessary to use appropriate delimiters to separate the individual elements (,) to define the elements and the rows (;).
Try this:
syms I1 I2 I3 V s
A= [(2.*s +2), - (2.*s + 1), -1; -(2.*s +1), (9.*s +1), -4.*s; -1, -4.*s, (4.*s +1 +1./s)];
B= [I1;I2;I3];
C=[V;0;0];
Eq = C == A * B;
[Isln] = solve(Eq, [I1,I2,I3]);
I1 = simplify(Isln.I1, 'Steps',100)
I2 = simplify(Isln.I2, 'Steps',100)
I3 = simplify(Isln.I3, 'Steps',100)
producing:
I1 =
(V*(20*s^3 + 13*s^2 + 10*s + 1))/(24*s^4 + 30*s^3 + 17*s^2 + 16*s + 1)
I2 =
(V*(s + 1)*(8*s^2 + 2*s + 1))/(24*s^4 + 30*s^3 + 17*s^2 + 16*s + 1)
I3 =
(V*s*(8*s^2 + 13*s + 1))/(24*s^4 + 30*s^3 + 17*s^2 + 16*s + 1)
EDIT — (10 Sep 2020 at 15:52)
To calculate them as impedances:
Z1 = simplify(V/I1, 'Steps',100)
Z2 = simplify(V/I2, 'Steps',100)
Z3 = simplify(V/I3, 'Steps',100)
producing:
Z1 =
(24*s^4 + 30*s^3 + 17*s^2 + 16*s + 1)/(20*s^3 + 13*s^2 + 10*s + 1)
Z2 =
3*s + (8*s^2 + 13*s + 1)/((s + 1)*(8*s^2 + 2*s + 1))
Z3 =
(24*s^4 + 30*s^3 + 17*s^2 + 16*s + 1)/(s*(8*s^2 + 13*s + 1))
.

추가 답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 9월 10일

0 개 추천

An alternate solution is to use the inv() or mldivide (\) operator to solve the equation. Since this seems to be the lalpalce transform of a circuit, the following also shows how to get the time-domain solution for a specific voltage signal (v).
syms s V(s) t
A = [(2*s+1) -(2*s+1) -1;
-(2*s+1) (9*s+1) -4*s;
-1 -4*s (4+1+1/s)];
C = [V; 0; 0];
I = A\C; % same as inv(A)*B but more efficient
% Let v is a constant signal, i.e., v=1
V1 = 1/s;
I1 = subs(I, V, V1);
i(t) = ilaplace(I1, s, t);
tv = 0:0.01:1;
iv = double(subs(i, t, tv));
plot(tv, iv.');

카테고리

도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기

제품

릴리스

R2020a

질문:

2020년 9월 10일

댓글:

2020년 9월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by