How to solve nonlinear Trigonometry equations in matlab
3 次查看(过去 30 天)
显示 更早的评论
Dear Friend I have a 5 nonlinear trigonometry equations with 5 parameters as following:
x*sin(z)-y*sin(k)=-2.061 ,
y*cos(k)-x*cos(z)=5.181 ,
x*cos(0.4904-z)+0.1*y*cos(0.4904+z)=0 ,
-1.032*cos(u)-0.1*y*sin(k)-0.2*x*sin(z)=-0.8821 ,
-1.032*sin(u)+0.1*y*cos(k)+0.2*x*cos(z)=-0.471 ,
How to calculate x,y,z,k,u? Best Regards
0 个评论
采纳的回答
Star Strider
2015-5-5
One possibility:
% MAPPING: b(1) = x, b(2) = y, b(3) = z, b(4) = k, b(5) = u
f = @(b) [b(1)*sin(b(3))-b(2)*sin(b(4))+2.061
b(2)*cos(b(4))-b(1)*cos(b(3))-5.181
b(1)*cos(0.4904-b(3))+0.1*b(2)*cos(0.4904+b(3))
-1.032*cos(b(5))-0.1*b(2)*sin(b(4))-0.2*b(1)*sin(b(3))+0.8821
-1.032*sin(b(5))+0.1*b(2)*cos(b(4))+0.2*b(1)*cos(b(3))+0.471];
B0 = rand(5,1)*2*pi;
[B,fv,xf,ops] = fsolve(f, B0);
ps = ['x'; 'y'; 'z'; 'k'; 'u'];
fprintf(1, '\n\tParameters:\n')
for k1 = 1:length(B)
fprintf(1, '\t\t%s = % .4f\n', ps(k1,:), B(k1))
end
that with one set of initial parameter estimates produces:
Parameters:
x = 0.9478
y = 5.8864
z = 1.6950
k = 0.5351
u = 1.1792
5 个评论
Lonny Thompson
2020-6-22
yes, you need optimization toolbox to use fsolve.
another way to solve is using the symbolic toolbox solve function.
Star Strider
2020-6-22
[B,fv] = fminsearch(@(b)norm(f(b)-0), B0)
It may not be as accurate, however it will provide decent parameter estimates.
.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Nonlinear Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!