Why does Matlab not manage to evaluate a certain variable in my code?

Hello,
I need to evaluate the variables psi1 and psi2 marked in the image (lines 42 and 43, I have also given the code below). Matlab has no issues in evaluating psi1 but is not able to evaluate psi2. I have let Matlab run overnight but it cannot provide a result. This seems very curious to me because the variables are very similar.
Can you please explain this behaviour?
clear all; close all; clc;
syms iL vC1 iLr vC2 Vg L R C1 C2 Lr D Ts s t
x = [iL; vC1; iLr;vC2]
u = Vg
y = vC2
A1 = [0 0 0 0;
0 0 -1/C1 0;
0 1/Lr 0 0;
0 0 0 -1/(R*C2)];
B1 = [1/L; 0;0;0];
E1 = [0 0 0 1];
F1 = [0]
A2 = [0 -1/L 0 -1/L;
1/C1 0 0 0;
0 0 0 0;
1/C2 0 0 -1/(R*C2)];
B2 = [1/L; 0;0;0];
E2 = E1
F2 = F1
Vg=12; V0 = 48; L = 100e-6;Lr = 5.6993e-07; C1 = 10e-6; C2=100e-6; P0 = 1000; R=V0^2/P0; R0 = sqrt(Lr/C1)
fs =100e3; Ts = 1/fs; Ws = 2*pi*fs; % ws for Vo = 12 V read from static characteristic
M = V0/Vg; D = 1-1/M
A1 = eval(A1)
A2 = eval(A2)
B1 = eval(B1)
B2 = eval(B2)
psi1 = eval(int(expm(A1*t),0,D*Ts)*B1)
psi2 = eval(int(expm(A2*t),t,0,(1-D)*Ts)*B2)

Answers (1)

Is this really the expression you want to evaluate?
int(expm(A2*t),t,0,(1-D)*Ts)*B2
The reason I ask is that it has a different number of arguments from
int(expm(A1*t),0,D*Ts)*B1
and I speculate that you didn't actually intend that.
(I did not dig into the implications of the different argument list myself.)

3 Comments

Thank you for your remark! I was not consistent with the arguments. However this doesn't seem to solve the issue.
psi1 = eval(int(expm(A1*t),t,0,D*Ts)*B1)
and
psi1 = eval(int(expm(A1*t),0,D*Ts)*B1)
give the same result since t is the only variable.
>> psi1 = eval(int(expm(A1*t),t,0,D*Ts)*B1)
psi1 =
0.0750
0
0
0
>> psi1 = eval(int(expm(A1*t),0,D*Ts)*B1)
psi1 =
0.0750
0
0
0
I don't really have a solution here, but I stripped away lots of your code, and I think the essence of your problem is that the second expression you are integrating is significantly more complicated than the first one. (Compare the two expressions displayed at the end of this code.) I don't have any experience with the Symbolic Math Toolbox, so I can't offer any more advice.
syms L R C1 C2 Lr t
A1 = [0 0 0 0;
0 0 -1/C1 0;
0 1/Lr 0 0;
0 0 0 -1/(R*C2)];
A2 = [ 0 -1/L 0 -1/L;
1/C1 0 0 0;
0 0 0 0;
1/C2 0 0 -1/(R*C2)];
V0 = 48;
L = 100e-6;
Lr = 5.6993e-07;
C1 = 10e-6;
C2 = 100e-6;
P0 = 1000;
R = V0^2/P0;
A1 = eval(A1);
A2 = eval(A2);
expm(A1*t)
ans = 
expm(A2*t)
ans = 
Yes, I think that the complexity of expm(A2*t) was the issue here. Stephen suggested to use vpa instead of eval and it worked. Thanks again!

Sign in to comment.

Categories

Asked:

on 12 Jan 2022

Commented:

on 16 Jan 2022

Community Treasure Hunt

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

Start Hunting!