Matlab 求值 fzero 第二个值怎么也求不出来 请大师帮忙
来源:学生作业帮 编辑:大师作文网作业帮 分类:数学作业 时间:2024/11/10 23:00:41
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
>>
第二个值明显错误,请大师帮忙
两个人答的都很好,奖励谁?
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
>>
第二个值明显错误,请大师帮忙
两个人答的都很好,奖励谁?
你的错误在于,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
.
再问: 你这图怎么画出来的?发shi_w_y@我163的,谢谢,
再答: 用 ezplot()函数画出来。 >> ezplot('y=2.0095*sqrt(x).*tan(0.7265*sqrt(x))-sqrt(5.6976-0.3205*x)',[-10 50 -100 100]),grid on
从图形看,有无数个解.
>> [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
.
再问: 你这图怎么画出来的?发shi_w_y@我163的,谢谢,
再答: 用 ezplot()函数画出来。 >> ezplot('y=2.0095*sqrt(x).*tan(0.7265*sqrt(x))-sqrt(5.6976-0.3205*x)',[-10 50 -100 100]),grid on