Difficulty creating this function to produce a plot

I'm having difficulty working out how to do this task, any help would be appreciated.
The displacement x(t) of a forced, undamped, oscillating spring mass system is given to be:
x = (F0/w(w^2-w0^2))(wSin(w0*t)-w0*Sin(wt))
where F0 is the amplitude of the forcing function, w is the natural frequency of the system and w0 is the frequency of the forcing function. Write a function m-file forced.m that, for defined values of w and w0, produces a plot of the variation of x/F0 for value of t in the range 0 =< t =< 500.
Use this m-file with the defined values w = 1 and w0 = 2, 1.2 and 1.02 in turn. The plots produces should illustrate the phenomenon of beats for the case w0 = 1.02, with the amplitude of the oscillation exhibiting a sinusoidal oscillation.
I'm not sure how I would plot x/F0, and I don't know what the 'phenomenon of beats' is, unless it is referring to Beats by Dre.
Attempt:
function forced(w,w0)
x=f0/(w*(w^2-w0^2))*(w*Sin(w0*t)-w0*Sin(w*t));
t=0:1:500;
plot(x/f0)
grid on
end
Of course, this isn't right, but I don't know where to go from here. It tells me that 'F0' has not been defined, but I haven't been given a value for F0. I'm also not sure where exactly I put the input variables w and w0 after I have made the function.

1 Comment

In your function, you are using f0 at the first line, but it has not been defined so Matlab cannot know its value.
w and w0 are ok because you give them as input of your function.

Sign in to comment.

Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Asked:

on 3 Nov 2017

Commented:

M
M
on 3 Nov 2017

Community Treasure Hunt

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

Start Hunting!