Error witth Matrix calculus

19 views (last 30 days)
zmath on 6 May 2015
Edited: Walter Roberson on 22 Sep 2021
Hi all,
I am trying to calculate such a system:
For which I already know the solution:
But when I put all this stuff into Matlab, I get the following error:
>> syms L C R s;
>> C = [[R + s*L,-s*L];[-s*L, R + s*L + 1/(s*C)]]
C =
[ R + L*s, -L*s]
[ -L*s, R + L*s + 1/(C*s)]
>>V = [[R + s*L,1];[-s*L,0]]
V =
[ R + L*s, 1]
[ -L*s, 0]
>> i2 = det(V)/det(C)
ans =
(C*L*s^2)/(C*R^2*s + 2*C*L*R*s^2 + R + L*s)
>> vo = i2/(s*C)
Error using symengine (line 59)
Operands are invalid.
Error in sym/privBinaryOp (line 903)
Csym = mupadmex(op,args{1}.s, args{2}.s, varargin{:});
Error in / (line 297)
X = privBinaryOp(A, B, 'symobj::mrdivide');
Why Matlab cannot perform such a calculation ? This is not the first time I perform these kind of calculations.
Instead, If I declare a variable C1, it all works:
>> syms C1
>> C = [[(R + s*L),-s*L];[-s*L, (R + s*L + 1/(s*C1))]]
C =
[ R + L*s, -L*s]
[ -L*s, R + L*s + 1/(C1*s)]
>> V = [[R + s*L,1];[-s*L,0]]
V =
[ R + L*s, 1]
[ -L*s, 0]
>> i2 = det(V)/det(C)/(s*C1)
i2 =
(L*s)/(C1*R^2*s + 2*C1*L*R*s^2 + R + L*s)
What's the problem with variable named C ? Thank you for yor help.

Answers (3)

John D'Errico
John D'Errico on 6 May 2015
The problem is NOT the name of the variable C, but what it contains and what you are doing.
LOOK at the line that had trouble.
vo = i2/(s*C)
i2 and s are scalars. C is a 2x2 matrix.
What do you expect matlab to do when you try to divide by a 2x2 matrix?
  1 Comment
John D'Errico
John D'Errico on 20 Sep 2021
Moved an answer to a comment by @zmath
"Ooops I did not realize I mixed matrix name and variable. I am feeling quiet stupid right now. Put this on the top 10 of MSQ. Bye."

Sign in to comment.

arvind thakur
arvind thakur on 20 Sep 2021
Edited: Walter Roberson on 22 Sep 2021
I have an error like below,
Error using plot
Data must be numeric, datetime, duration or an array convertible to double.
Error in pressuremodel (line 36)
my code is:
%% pressure at crack wake due to bridgindg after application of remote stress
close all
syms x a w
Ef=427000*10^6; % in Pa
j=int((S*H)./(sqrt(a-x)), [0 ao]);
L=int(((S-c)*H)./(sqrt(a-x)), [ao a]);
help can appreciated in advance.
  1 Comment
John D'Errico
John D'Errico on 20 Sep 2021
PLEASE DON'T post a completely new question as an answer. This is NOT an answer to that question, and your problem is not even remotely the same. Repost the question AS a question on Answers. I'll delete this answer soon.

Sign in to comment.

VBBV on 22 Sep 2021
Edited: VBBV on 22 Sep 2021
syms C1 L C R s;
C = [[(R + s*L),-s*L];[-s*L, (R + s*L + 1/(s*C1))]];
C = 
V = [[R + s*L,1];[-s*L,0]];
V = 
i2 = det(V)/det(C)/(s*C1);
i2 = 
vo = i2./(s*C)
vo = 
Use the element wise division operator as above

Community Treasure Hunt

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

Start Hunting!