Help creating a function file

5 次查看(过去 30 天)
Steven
Steven 2012-3-17
回答: Steve Miller 2022-12-21
For this problem I need to create a function file that computes distance x and use my function to plot x versus W.
Here is the problem:
Figure P20 shows a mass-spring model of the type used to design packaging systems and vehicle suspensions, for example. ('of course I am aware you cannot see this figure').The springs exert a force that is proportional to their compression, and the proportionality constant is the spring constant 'k'. The two side springs provide additional resistance if the weight 'W' is gently placed, it moves through a distance 'x' before coming to rest. From statics, the weight force must balance the spring forces at this new position. Thus
W=(k1)*x [ if x < d ]
W=(k1)*x + 2(k2)*(x-d) [ if x >= d ]
These relations can be used to generate the plot of x versus W.
a) Create a function file that computes the distance x, using the input parameters W, k1, k2, and d. Test your function for the following two cases, using the values k1 = 10^4 N/m; k2 = 1.5 x 10^4 N/m; d = 0.1 m.
b) Use your function to plot x versus W for 0 <= W <= 3000 N for the values of k1,k2,and d given in part a.
PLEASE HELP!
Thank you..
  2 个评论
Walter Roberson
Walter Roberson 2012-3-17
http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer
Joseph Areeda
Joseph Areeda 2012-3-17
Steven,
It sounds a lot like you're asking us to do your homework for you.
Please read Walter's link. He's answered a lot of questions on these pages for us so I'm sure he's trying to help.
If your question is how to write a Matlab function see http://www.mathworks.com/help/techdoc/ref/function.html
If your question is how to plot the results see: http://www.mathworks.com/help/techdoc/ref/plot.html
In general, I've had good luck googling Matlab <what programming tool I want to use>.
If your question is will I do your homework for you, the answer is no.

请先登录,再进行评论。

回答(1 个)

Steve Miller
Steve Miller 2022-12-21

类别

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