for loop with fminsearch

1 visualizzazione (ultimi 30 giorni)
onur karakurt
onur karakurt il 30 Set 2023
Commentato: Star Strider il 30 Set 2023
%I couldnt make array values of Theta_2
u=deg2rad(13)
eqn1= @(t1, u) u+atan(sin(t1)./(1-cos(t1)))-pi/2 % theta1 t1 olarak tanımlanmıştır.
Theta_1_initial= (fminsearch(@(t1)norm(eqn1(t1, u)),u))
Theta_1=linspace(Theta_1_initial,pi/2,100)
for i=1;100
Theta_2(i)=THETA (Theta_1(i),u)
end
function [Theta_2] = THETA (Theta_1,u)
eqn=@(Theta_2,Theta_1,u) cos(Theta_2)+sin(Theta_2).*tan(pi/2-atan(sin(Theta_2)./(cos(Theta_1)+sin(Theta_1).*tan(u)-cos(Theta_2))))-cos(Theta_1)-sin(Theta_1).*tan(u);
Theta_2=fminsearch(@(Theta_2)norm(eqn(Theta_2,Theta_1,u)),Theta_1);
end

Risposta accettata

Star Strider
Star Strider il 30 Set 2023
There is a typographical error:
for i=1;100
↑← HERE
Change that to a colon and it works —
%I couldnt make array values of Theta_2
u=deg2rad(13)
u = 0.2269
eqn1= @(t1, u) u+atan(sin(t1)./(1-cos(t1)))-pi/2 % theta1 t1 olarak tanımlanmıştır.
eqn1 = function_handle with value:
@(t1,u)u+atan(sin(t1)./(1-cos(t1)))-pi/2
Theta_1_initial= (fminsearch(@(t1)norm(eqn1(t1, u)),u));
Theta_1=linspace(Theta_1_initial,pi/2,100);
for i=1:100
Theta_2(i)=THETA (Theta_1(i),u);
end
Theta_2
Theta_2 = 1×100
0.4311 0.4651 0.4764 0.4876 0.4740 0.5102 0.5215 0.5328 0.5440 0.5553 0.5666 0.6068 0.5892 0.6005 0.6117 0.6230 0.6343 0.6456 0.6569 0.6682 0.6455 0.6907 0.7020 0.7133 0.7246 0.6991 0.7471 0.7963 0.7697 0.7419
function [Theta_2] = THETA (Theta_1,u)
eqn=@(Theta_2,Theta_1,u) cos(Theta_2)+sin(Theta_2).*tan(pi/2-atan(sin(Theta_2)./(cos(Theta_1)+sin(Theta_1).*tan(u)-cos(Theta_2))))-cos(Theta_1)-sin(Theta_1).*tan(u);
Theta_2=fminsearch(@(Theta_2)norm(eqn(Theta_2,Theta_1,u)),Theta_1);
end
.
  2 Commenti
onur karakurt
onur karakurt il 30 Set 2023
Thanks so much
Star Strider
Star Strider il 30 Set 2023
As always, my pleasure!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Prodotti


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by