Matlab 求值 fzero 第二个值怎么也求不出来 请大师帮忙clear>> x=[0:0.5:5];>> y=2.0095*sqrt(x).*tan(0.7265*sqrt(x))-sqrt(5.6976-0.3205*x);>> plot(x,real(y),'r','LineWidth',1.5);>> h=line([4.6748,4.6749],[0,0]);>> h=line([0,5],[
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/28 11:36:31
Matlab 求值 fzero 第二个值怎么也求不出来 请大师帮忙clear>> x=[0:0.5:5];>> y=2.0095*sqrt(x).*tan(0.7265*sqrt(x))-sqrt(5.6976-0.3205*x);>> plot(x,real(y),'r','LineWidth',1.5);>> h=line([4.6748,4.6749],[0,0]);>> h=line([0,5],[
Matlab 求值 fzero 第二个值怎么也求不出来 请大师帮忙
clear
>> x=[0:0.5:5];
>> y=2.0095*sqrt(x).*tan(0.7265*sqrt(x))-sqrt(5.6976-0.3205*x);
>> plot(x,real(y),'r','LineWidth',1.5);
>> h=line([4.6748,4.6749],[0,0]);
>> h=line([0,5],[0,0]);
>> hold on
>> plot(x,imag(y),'bo');
>> grid
f=@(x)real(2.0095*sqrt(x).*tan(0.7265*sqrt(x))-sqrt(5.6976-0.3205*x));
[x1,f1,exitflag1]=fzero(f,1);
[x2,f2,exitflag2]=fzero(f,4);
x=[x1,x2];
f=[f1,f2];
>> x
x =
1.2228 4.6749
>> f
f =
1.0e+016 *
0.0000 1.5338
>> x1
x1 =
1.2228
>> f1
f1 =
4.4409e-016
>> x2
x2 =
4.6749
>> f2
f2 =
1.5338e+016
>>
第二个值明显错误,请大师帮忙
两个人答的都很好,奖励谁?
Matlab 求值 fzero 第二个值怎么也求不出来 请大师帮忙clear>> x=[0:0.5:5];>> y=2.0095*sqrt(x).*tan(0.7265*sqrt(x))-sqrt(5.6976-0.3205*x);>> plot(x,real(y),'r','LineWidth',1.5);>> h=line([4.6748,4.6749],[0,0]);>> h=line([0,5],[
你的错误在于,x0的初值选择不正确.因初值离真值较远,所以出现错误.
从图形看,有无数个解.
>> [x,fval,exitflag]=fzero(f,1)
x =
1.2228
fval =
4.4409e-016
exitflag =
1
>> [x,fval,exitflag]=fzero(f,20)
x =
18.6994
fval =
2.7948e-015
exitflag =
1
>> [x,fval,exitflag]=fzero(f,80)
x =
74.7977
fval =
1.1179e-014
exitflag =
1
.
程序选的x太少了。 x=[0:0.05:5]; >> y=2.0095*sqrt(x).*tan(0.7265*sqrt(x))-sqrt(5.6976-0.3205*x); >> plot(x,real(y),'r','LineWidth',1.5); >> h=line([0,5],[0,0]); >> grid on f=@(x)real(2.0095*sqrt(x).*tan(0.7265*sqrt(x))-sqrt(5.6976-0.3205*x));f=@(x)real(2.0095*sqrt(x).*tan(0.7265*sqrt(x))-sqrt(5.6976-0.3205*x)); >> [x2,f2,exitflag2]=fzero(f,4); >> x2 x2 = 4.6749 结果正确
收起