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.
답변 (2개)
Geoff Hayes
2016년 2월 28일
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.
Roger Stafford
2016년 2월 28일
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.
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!