Question
Matlab code Function Name: physics Inputs: ( double ) 1xM vector of time values ( double ) 1xM vector of velocity values ( double )
Matlab code
Function Name: physics
Inputs:
( double ) 1xM vector of time values
( double ) 1xM vector of velocity values
( double ) Degree that best fits velocity vs time data
Outputs:
None
Plot Outputs:
1. A plot with subplots of Velocity vs. Time, Numerical Derivative vs. Time, and Analytical Derivative vs. Time
Background:
You are in PHYS 2211, and you are tired of plotting velocity and acceleration graphs by hand. Luckily, you just learned how to plot and to find derivatives numerically and analytically in MATLAB.
Function Description:
Write a function that first plots the velocity values vs. time and then estimates and plots the acceleration in two different ways. Your function should do the following:
Create a 2x2 subplot.
Plot the velocity vs time graph in black in the top left position.
Approximate the acceleration data by finding the numerical derivative of the velocity. Plot
the numerical acceleration vs time graph in red in the top right position.
Now find the best-fit polynomial of the velocity data using the order given by the third input. Then, find a second approximation for the acceleration data by taking the analytical derivative of this polynomial and evaluating the derivative at the original time
values. Plot your derivative in green in the bottom right position.
Notes:
? The subplot in the bottom left position should not have a plot.
? Make the axes for all the subplots square.
? When plotting the numerical derivative, leave off the last time value, so the vector
lengths are the same.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started