for loop with fminsearch
1 view (last 30 days)
Show older comments
onur karakurt
on 30 Sep 2023
Commented: Star Strider
on 30 Sep 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
0 Comments
Accepted Answer
Star Strider
on 30 Sep 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)
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
Theta_2
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 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!