Homework Help, Basic function

Create the function [t v] = velinput that asks the user to enter the following inputs: M = Mass (kg) g = gravity (m/s 2 ) Cd = drag coefficient (kg/m) Tend = End Time N = number of points in time Show = Plot Function (Y or N) Set the initial time to zero
So, I understand all the inputting part. I just don't understand the use of function. I tried help function and that didn't help to much either. Im just really stuck.

Answers (2)

cwachts - the first line of your assignment is giving you the function name and signature. In the MATLAB editor, create a new file and then let the following be your first line of code
function [t v] = velinput
From the menu, save the file and it should be saved with the name of your function as velinput.m. When you run this function, you will do so from the command prompt by typing in
>> velinput
The body of your function will have all of the code necessary to request some information from the user and to build the plot.
Though the statement of the problem doesn't appear to require a computation which uses these inputs, I would think doing so would be implicit upon receiving a 'Y' for 'Show'. To do the computation will require the solution of a differential equation to solve for velocity versus time, courtesy of Isaac Newton and his laws of motion. You can probably use 'ode45'. See
http://www.mathworks.com/help/matlab/ref/ode45.html
for details.

Categories

Find more on Programming in Help Center and File Exchange

Asked:

on 28 Feb 2016

Answered:

on 28 Feb 2016

Community Treasure Hunt

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

Start Hunting!