Help creating a function file

10 views (last 30 days)
Steven on 17 Mar 2012
Answered: Steve Miller on 21 Dec 2022
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.
Thank you..
Joseph Areeda
Joseph Areeda on 17 Mar 2012
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
If your question is how to plot the results see:
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.

Sign in to comment.

Answers (1)

Steve Miller
Steve Miller on 21 Dec 2022

Community Treasure Hunt

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

Start Hunting!