How do I plot a function over a specific range of x values?
146 views (last 30 days)
Show older comments
I am trying to graph the function y=exp(-.2x)*cos(2.1x) over the x values of 0 to 4. I have to use the function and the f plot method. I tried to do this by using the method of "fplot(fun1,[0 4])," but this did not work, as it is asking me to enter the value of x. I believe the problem lies in my function, which I have attached. If anyone has any advice, I would greatly appreciate it.
0 Comments
Accepted Answer
William
on 23 Mar 2021
Erica,
I think fplot() will work if it is called correctly. If you want to use it, you need to define the function so that it can handle a vector input for x. In your case, this means that you should use a ".*" operator to multiply the two functions together, as in the following:
func = @(x) exp(-.2*x).*cos(2.1*x)
fplot(func,[0,4])
0 Comments
More Answers (0)
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!