matlab 解方程组问题

来源:百度知道 编辑:UC知道 时间:2024/05/17 21:55:49
编辑了一个函数fun2(j,w),如下
function fun2(j,w)
[x,y]=solve('sind(x)*cosd(y)=cosd(w)*sind(j+71.78),cosd(x)*cosd(y)*cosd(79.74)=sind(y)*sind(79.74)-sind(w)')
end

然后命令并运行,出现如下情况,怎么算不出来啊,问题出在哪儿,各位不吝赐教,本人初学者,望稍详细~
j=-71.78;
>> w=79.74;
>> fun2(j,w)
Warning: Explicit solution could not be found.
> In solve at 140
In fun2 at 2

x =

[ empty sym ]

y =

[]

用fsolve吧。只是不知道怎么传递j和w。暂时这样将就,让我再查查资料。直接运行即可。

function fun2
X = fsolve(@myfun,[2 3],optimset('Display','iter'))
function f=myfun(X)
x=X(1);y=X(2);%j=c(1);w=c(2);
j=-71.78; w=79.74;
f(1)=sind(x)*cosd(y)-cosd(w)*sind(j+71.78);
f(2)=cosd(x)*cosd(y)*cosd(79.74)-sind(y)*sind(79.74)+sind(w);

结果:

Norm of First-order Trust-region
Iteration Func-count f(x) step optimality radius
0 3 1.23392 0.0192 1
1 6 1.19572 1 0.019 1
2 9 1.10257 2.5 0.0183 2.5
3 12 0.885502 6.25 0.0164 6.25
4 15 0.4536 15.625 0.0112 15.6
5 18 0.0206981