I can not write piecewise function
Afficher commentaires plus anciens
I need to write piecewise function and plot it on matlab. But I couldn't do it. Here is my code. I need T_16 in terms of theta_12 with following conditions:
T_16 = 10*theta_12/0.17 if 0<=theta_12<=0.17
10 if 0.17<=theta_12<=3.5
215.88-10*theta_12/0.17 if 3.5<t=heta_12<=3.68
0 if 3.68<=theta_12<=2*pi()
clear; close all;
AB=140; A0_A=30; A0_B0=70; B0_Q=80; Q_C0=30;
sampling=3600;
theta_12=linspace(0,2*pi(),sampling+1);
theta_12=theta_12(1:end-1)';
theta_13=zeros(sampling,1);
s_43=zeros(sampling,1);
s_65=zeros(sampling,1);
theta_16=zeros(sampling,1);
for a=1:1:sampling
s_43(a)=(A0_A*A0_A*(1+2*(A0_B0/A0_A)*cos(theta_12(a)))+A0_B0*A0_B0)^0.5;
theta_13(a)=atan2(A0_A*sin(theta_12(a)),A0_B0+A0_A*cos(theta_12(a)));
theta_16(a)=atan2(-(AB-s_43(a))*sin(theta_13(a))-B0_Q,-(AB-s_43(a))...
*cos(theta_13(a))+Q_C0);
s_65(a)=(Q_C0*Q_C0+B0_Q*B0_Q+(AB-s_43(a))*(AB-s_43(a))-...
2*Q_C0*(AB-s_43(a))*cos(theta_13(a))+2*B0_Q*...
(AB-s_43(a))*sin(theta_13(a)))^0.5;
end
figure (1)
plot(theta_12*180/pi(),theta_13*180/pi(),...
theta_12*180/pi(),theta_16*180/pi());
legend("theta_{13}","theta_{14}");
xlabel("Angle theta_{12} (degree)");
ylabel("Angle (degree)");
title("Angles");
figure (2)
plot(theta_12*180/pi(),s_43,theta_12*180/pi(),s_65);
legend("s_{43}","s_{65}");
xlabel("Angle theta_{12} (degree)");
ylabel("Distance mm");
title("Angles");
syms theta_12
T_16 = piecewise((0<theta_12)&(theta_12<0.17),10*theta_12/0.17 ...
,(0.17<theta_12)&(theta_12<3.5),10 ...
,(3.5<theta_12)&(theta_12<3.68),(215.88-10*theta_12/0.17) ...
,(3.68<theta_12)&(theta_12<(2*pi())),0);
fplot(T_16)
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Point Cloud Processing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
