How to solve nonlinear Trigonometry equations in matlab
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Mohsen
am 5 Mai 2015
Kommentiert: Star Strider
am 22 Jun. 2020
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 Kommentare
Akzeptierte Antwort
Star Strider
am 5 Mai 2015
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 Kommentare
Lonny Thompson
am 22 Jun. 2020
yes, you need optimization toolbox to use fsolve.
another way to solve is using the symbolic toolbox solve function.
Star Strider
am 22 Jun. 2020
[B,fv] = fminsearch(@(b)norm(f(b)-0), B0)
It may not be as accurate, however it will provide decent parameter estimates.
.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Nonlinear Optimization finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!