How do I plot a function over a specific range of x values?
49 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Erica Dawn Miller
el 23 de Mzo. de 2021
Respondida: William
el 23 de Mzo. de 2021
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 comentarios
Respuesta aceptada
William
el 23 de Mzo. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!