for loop with fminsearch
1 次查看(过去 30 天)
显示 更早的评论
%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 个评论
采纳的回答
Star Strider
2023-9-30
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
.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!