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
5 views (last 30 days)
Show older comments
%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 Comments
Answers (1)
KSSV
on 2 Jun 2017
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'})
2 Comments
See Also
Categories
Find more on Graph and Network Algorithms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!