How to solve nonlinear Trigonometry equations in matlab
1 回表示 (過去 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 で Linear Model Identification についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!