vertical throw in matlab?

조회 수: 7 (최근 30일)
Isak N.
Isak N. 2020년 4월 13일
답변: Mehmed Saad 2020년 4월 14일
So I have the following situation: Phase one: something is being accelerated using a spring with a certain lenght, hence gaining a certain velocity. Phase two: vertical throw with said starting velocity. My question: how am i able to plot these two phases (acc., velocity and position) in one graph? If I'd go with the classical approach learned in physics class I'd end up with two different equations for phase one and two, so how can i combine them? don't know if this makes sense since i am an absolute beginner at matlab. I tried plotting both phases separately but that kind of defeats its purpose. any tips?
  댓글 수: 5
KALYAN ACHARJYA
KALYAN ACHARJYA 2020년 4월 13일
Isak N.
Isak N. 2020년 4월 13일
like the first one! I'd like to have the time on the x-axis and the other quantities on the y-axis. But the thing i am struggling with is fitting two different equations for, lets say for instance: the position, into one graph. equation 1 is for phase one (t=0 until the time the spring stops accelerating my object) and equation 2 is for phase two (t=time the spring stops accelerating my object until t=object lands).

댓글을 달려면 로그인하십시오.

답변 (2개)

Image Analyst
Image Analyst 2020년 4월 13일
I'd use three plots, all plotted with time as the x axis. Why? Because they could all have vastly different ranges! Let's say you dropped something from an airplane. The distance plot could range from 0 to 40,000 feet while the acceleration would be a constant 9.8 m/s^2. And velocity could be from 0 to 195 km/hour. So plotting the acceleration on the same plot as the position would make the acceleration plot virtually unnoticeable and the velocity barely noticeable. Of course you could do it if you want:
plot(t, acc, '-'); % Plot acceleration vs. time.
hold on;
plot(t, velocity, '-');
plot(t, position, '-');
legend('Acceleration', 'Velocity', 'Position');
grid on;
xlabel('Time', 'FontSize', 15);
ylabel('Accel, Velocity, or Position', 'FontSize', 15);

Mehmed Saad
Mehmed Saad 2020년 4월 14일
Define three different times for acceleration, velocity and position if there time is different (remember that each time vector size must be equal to corresponding accelaration vector, velocity vector and position vector)
t_acc = starting_acc_point:sampling_time:ending_acc_point;
t_vel = starting_vel_point:sampling_time:ending_vel_point;
t_pos = starting_pos_point:sampling_time:ending_pos_point;
Now plot them
figure,plot(t_acc,acc),hold on,plot(t_vel,vel),hold on,plot(t_pos,pos)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by