作业帮 > 数学 > 作业

已知60=x*2*sin(pi*74/(4*x)),用matlab解此方程的语句该怎么写?

来源:学生作业帮 编辑:搜搜做题作业网作业帮 分类:数学作业 时间:2024/06/26 05:37:39
已知60=x*2*sin(pi*74/(4*x)),用matlab解此方程的语句该怎么写?
已知60=x*2*sin(pi*74/(4*x)),用matlab解此方程的语句该怎么写?
solve('60=x*2*sin(pi*74/(4*x))')

ans =

-31.281066120310786755821961868485
不过函数是偶函数,31.281066120310786755821961868485也因该是一个解,
通过绘图也可以看出

当然也可以用数值方法,但是对初值的依赖很大,你可以先绘图大致确定解的位置.
在图可以看出解大约在30和-30左右所以有以下程序
>> f=@(x)60-x*2*sin(pi*74/(4*x));
>> fsolve(f,-30)

Equation solved.

fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance,and
the problem appears regular as measured by the gradient.

<stopping criteria details>

ans =

  -31.2811

>> fsolve(f,30)

Equation solved.

fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance,and
the problem appears regular as measured by the gradient.

<stopping criteria details>

ans =

   31.2811
再问: 如果是y=x*2*sin(pi*74/(4*x)),y=0:0.1:74,要求x大于零的根呢?
再答: 用一个for循环,循环给y赋值,用fsolve解,不过初值就不好定了。
再问: clear; clc; y=30:0.5:74; f=@(x)y-x*2*sin(pi*74/(4*x)); z=fsolve(f,60); z ; 这么写错在哪儿呢?
再答: 改为这样,y值要分别赋给f。 options = optimset('display','off'); sol=[]; y=30:0.5:74; for ii=1:length(y); f=@(x)y(ii)-x.*2.*sin(pi*74./(4*x)); sol=[sol,fsolve(f,60,options)]; end sol sol = Columns 1 through 7 23.6711 23.7701 23.8698 23.9701 24.0710 24.1726 24.2749 Columns 8 through 14 24.3779 24.4816 24.5860 24.6911 24.7970 24.9037 25.0111 Columns 15 through 21 25.1193 25.2284 25.3382 25.4489 25.5604 25.6728 25.7861 Columns 22 through 28 25.9003 26.0154 26.1314 26.2484 26.3663 26.4852 26.6052 Columns 29 through 35 26.7261 26.8481 26.9712 27.0954 27.2206 27.3470 27.4746 Columns 36 through 42 27.6033 27.7332 27.8643 27.9967 28.1303 28.2652 28.4015 Columns 43 through 49 28.5391 28.6780 28.8184 28.9602 29.1035 29.2482 29.3945 Columns 50 through 56 29.5423 29.6917 29.8428 29.9954 30.1498 30.3059 30.4638 Columns 57 through 63 30.6235 30.7850 30.9484 31.1138 31.2811 31.4504 31.6218 Columns 64 through 70 31.7953 31.9710 32.1489 32.3290 32.5115 32.6964 32.8837 Columns 71 through 77 33.0734 33.2658 33.4608 33.6584 33.8589 34.0621 34.2683 Columns 78 through 84 34.4774 34.6897 34.9050 35.1236 35.3455 35.5708 35.7996 Columns 85 through 89 36.0321 36.2682 36.5082 36.7521 37.0000 >>