I need help to graph particle's (3D) and declare x,y,z functions of time describing the particle's path, and calculate position ,velocity and acceleration by matlab and simulink, which commands do ı have to use? thanks
4 次查看(过去 30 天)
显示 更早的评论
%position vector r=xi+yj+zk
%velocity vector v
%acceleration vector a
t=0:.5:10;
x=2*cos(t);
y=1.3+2.7*t.^2-.031*t.^3;
z=2.4+.14*t.^3;
figure;
plot(x,y,z,t)
0 个评论
回答(1 个)
KSSV
2017-6-2
t=0:.5:10;
%%position
x=2*cos(t);
y=1.3+2.7*t.^2-.031*t.^3;
z=2.4+.14*t.^3;
figure;
hold on
plot3(x,y,z,'r')
%%velocity
dt = unique(diff(t)) ;
dx = diff(x)/dt ;
dy = diff(y)/dt ;
dz = diff(z)/dt ;
plot3(dx,dy,dz,'b') ;
%%acceleration
ddx = diff(dx)/dt ;
ddy = diff(dy)/dt ;
ddz = diff(dz)/dt ;
plot3(ddx,ddy,ddz,'g') ;
legend({'position','velocity','acceleration'})
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Function Creation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!