Syms and solver help
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Star Strider
2021-3-26
编辑:Star Strider
2021-3-26
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Number Theory 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!