Syms and solver help
3 views (last 30 days)
Show older comments
Matthew Myers
on 25 Mar 2021
Commented: Star Strider
on 28 Mar 2021
Hello all,
I am taking a resonant converters class and I am trying to use MATLAB to solve an equation that relates frequency and Load to a duty cycle for a converter I am looking at. I entered my equation below and when I didn't have success getting the solver to work( I am pretty sure that for my Rl min of 5 ohms and the frequency of 400,000Hz, I should get a D = 0.5), I tried to plot it as well, but I didn't succeed in that either. Could anyone help me understand my issues with the solver and also why I can't plot this?
(sorry for not including C before
C = 2.533e-8
f = 400e3;
Rl_min = 5;
syms D
S = double(solve((2*pi*f*C*Rl_min) == 1/(2*pi)*(1-2*pi^2*(1-D)^2-cos(2*pi*D)+(2*pi*(1-D)+sin(2*pi*D))^2/(1-cos(2*pi*D))),D))
y1 = (2*pi*f*C*Rl_min);
y2 = (1/(2*pi)*(1-2*pi^2*(1-D)^2-cos(2*pi*D)+(2*pi*(1-D)+sin(2*pi*D))^2/(1-cos(2*pi*D))));
x = linspace(0,1);
plot(x,y1,x,y2)
0 Comments
Accepted Answer
Star Strider
on 26 Mar 2021
Edited: Star Strider
on 26 Mar 2021
The code apparently works (although ‘C’ is missing, and since double does not allow for symbolic variables to be present, ‘S’ will be empty). To see ‘S’ with symbolic variables, use vpa instead of double.
As for the plots, try this:
C = 2.533e-8;
f = 400e3;
Rl_min = 5;
syms D
S = double(solve((2*pi*f*C*Rl_min) == 1/(2*pi)*(1-2*pi^2*(1-D)^2-cos(2*pi*D)+(2*pi*(1-D)+sin(2*pi*D))^2/(1-cos(2*pi*D))),D))
y1 = (2*pi*f*C*Rl_min);
y2 = (1/(2*pi)*(1-2*pi^2*(1-D)^2-cos(2*pi*D)+(2*pi*(1-D)+sin(2*pi*D))^2/(1-cos(2*pi*D))));
x = linspace(0,1);
figure
fplot(y1,[0 1])
hold on
fplot(y2,[0 1])
hold off
set(gca,'YScale','log')
grid
EDIT — (26 Mar 2021 at 00:43)
With the addition of a value for ‘C’:
S =
-2.264999999973986e+02
Since ‘S’ does not have a symbolic solution, likely because ‘D’ is also an argument to the trigonometric functions.
The plots change a bit, however the code does not.
4 Comments
More Answers (0)
See Also
Categories
Find more on Number Theory in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!