plot graph with value when finding fzero

조회 수: 4 (최근 30일)
Paranee Sawad
Paranee Sawad 2019년 3월 20일
댓글: Paranee Sawad 2019년 3월 21일
Dear all,
I have question how to let it plot the graph while finding fzero
frad = 220;
rpm = 20000;
m =3;
alpha = 0.1;
R0 = 0.015;
R1 = 0.020;
rpmtoms = rpm*pi*(R0+R1)/(60);
B=pi*(R0+R1)/(m);
L=R1-R0;
ita=0.01; %from prof.
h0 = 0.00002;
k = B*tan(alpha*pi/180)/h0;
% fu = -(6*ita*rpmtoms*L*B^2)*(-log(k+1)+(2*k)/(k+2))/((k^2)*(h0^2));
f = @(h0) (-(6*ita*rpmtoms*L*B^2)*(-log(k+1)+(2*k)/(k+2))/((k^2)*(h0^2))) - frad;
h0 = fzero(f,h0)
I would like to see the graph because it seems like it depends on the initial value i set so i am not sure how much should i set? and my answer would be close to zero like in 1e-6 but cannot set it to zero. i read in some matlab questions i need to set the range for my h0 but in this case since the result close to zero but cannot be zero.
Thank you
  댓글 수: 10
Walter Roberson
Walter Roberson 2019년 3월 21일
[h0, fval] = fzero(f, [sqrt(realmin), 1E150])
Paranee Sawad
Paranee Sawad 2019년 3월 21일
Dear Walter Roberson,
i used to try this but it does not work but now it works. Thank you very much ^__^

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

답변 (1개)

Andrea Monfredini
Andrea Monfredini 2019년 3월 20일
You can substitute the equation expression of the operators * / and ^ with the respective dot operators
f = @(h0) (-(6.*ita.*rpmtoms.*L.*B.^2).*(-log(k+1)+(2.*k)./(k+2))./((k.^2).*(h0.^2))) - frad;
and then use semilogx to see a clearer representation of your function. Adjust the arguments of t to your needs.
t=linspace(0,h0*100,1000);
figure()
semilogx(t,f(t))
hold on
yline(0)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by