Need help on Matlab grader problem skydiver
2 views (last 30 days)
Show older comments
The code:
[height,time]=skydiverdatagen
will generate test data of a skydiver falling. The values of height will be measured in meters and they will be positive except for the last one which is 0. The values for time are evenlyspaced and start at 0 and the rest are positive.
From this data you need to calculate several quantities
1 Terminal Velocity before the parachute is pulled. This is simply the largest velocity during the entire the jump. Take the absolute value so that you get a positive value. You must store this as:
TV1
2 Terminal Velocity after the parachute is pulled. This is velocity that the skydiver will hit the ground at. In other words, this is the final velocity.Take the absolute value so that you get a positive value. You must store this as:
TV2
3 The time the parachute was pulled. That is the moment in time when acceleration first becomes positive. You must store this as:
PT
4 The maximum acceleration experienced by the skydiver prior to hitting the ground. Take the absolute value so that you get a positive value. You must store this as:
MA
Each of these values, must be calculated using central difference derivatives. You answers will need to be accurate for full credit.
I can get the TV1 TV2 and PT but cannot get the MA correct .
I currently have this code:
[height,time]=skydiverdatagen;
velocity = zeros(size(height));
velocity(2:end-1) = (height(3:end) - height(1:end-2)) ./ (time(3:end) - time(1:end-2));
acceleration = zeros(size(height));
acceleration(2:end-1) = (velocity(3:end) - velocity(1:end-2)) ./ (time(3:end) - time(1:end-2));
TV1 = max(abs(velocity));
TV2 = abs(velocity(end-1));
PT = time(find(acceleration > 0, 1, 'first'));
MA = max(abs(acceleration(1:end-1)));
6 Comments
Vidhi Agarwal
on 8 Jul 2025
Edited: Vidhi Agarwal
on 8 Jul 2025
I understand that the maximum acceleration, is likely causing the issue. The code for calculation of "MA" is:
MA = max(abs(acceleration(1:PT_index-1)));
- The acceleration computed at index i uses velocity(i+1) and velocity(i-1), so the value at acceleration(i) corresponds to the time at time(i).
- When you do acceleration(1:PT_index-1), you are excluding the acceleration at the moment the parachute deploys, which is probably the maximum (since the acceleration spike happens when the chute opens).
- The maximum acceleration experienced is typically at the moment the parachute opens.
- So try including up to and including PT_index.
So the change code for "MA" calculation is given below:
MA = max(abs(acceleration(1:PT_index)));
Hope this helps!
Answers (0)
See Also
Categories
Find more on Matrix Indexing 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!