필터 지우기
필터 지우기

Syms and solver help

조회 수: 3 (최근 30일)
Matthew Myers
Matthew Myers 2021년 3월 25일
댓글: Star Strider 2021년 3월 28일
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)

채택된 답변

Star Strider
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
Matthew Myers
Matthew Myers 2021년 3월 28일
Sorry, I forgot to accept this answer. Thank you for the help Start Strider, I appreciate it!
-Matthew
Star Strider
Star Strider 2021년 3월 28일
As always, my pleasure!
Thank you for returning to Accept it!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by