Write a function m-file which given any real x returns f(x) (Hint: the floor function may help here).
1 view (last 30 days)
Show older comments
A periodic function with period 3 is defined on the interval 0 ≤ x ≤ 3 by:
f(x) = 2sqrt(x), for 0 ≤ x ≤ 1
f(x) = 3-x, for 1 ≤ x ≤ 3
QUESTION: Write a function m-file which given any real x returns f(x) (Hint: the floor function may help here).
1 Comment
Geoff Hayes
on 26 Nov 2014
Set - what is your question? This homework question seems straightforward, but is there something in particular that you are getting stuck on? Concentrate first on writing your function for the interval [0,3], and once you have that working, then try to figure out how the period of the function can be used for other inputs.
Answers (1)
Image Analyst
on 27 Nov 2014
I would think the rem() function would be better than floor. For example if you wanted to pass in 34.567, it should give the same f(x) output as 1.567.
>> rem(34.567, 3)
ans =
1.567
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!