# Error witth Matrix calculus

49 views (last 30 days)

Show older comments

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.

##### 0 Comments

### Answers (3)

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
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."

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)

plot(a,K1,'.-b');

my code is:

%% pressure at crack wake due to bridgindg after application of remote stress

clc

close all

clear

a=0.001:0.0002:0.0018;

syms x a w

%x=1.0:0.1:1.98;

Ef=427000*10^6; % in Pa

Em=89000*10^6;

Ec=184000*10^6;

%mu=0.2825;

%v=0.36;

ao=0.001;

w=0.00512;

%R=.0725;

S=198*10^6;

%tow=20;

m1=0.6147+17.1844*(a.^2./w^2)+8.7822*(a.^6./w^6);

m2=0.2502+3.2889*(a.^2./w^2)+70.0444*(a.^6./w^6);

H=(1+m1*((a-x)./a)+m2*((a-x)./a).^2);

c=S*((w./(w-ao))+6*w*ao*((0.5*(w-ao)-(x-ao))./(w-ao)^3));

j=int((S*H)./(sqrt(a-x)), [0 ao]);

L=int(((S-c)*H)./(sqrt(a-x)), [ao a]);

K=sqrt(2/3.14)*(j+L);

K1=((K*(Em./(Ec)))./10^7);

plot(a,K1,'.-b');

help can appreciated in advance.

##### 1 Comment

John D'Errico
on 20 Sep 2021

### See Also

### Community Treasure Hunt

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

Start Hunting!