How do I plot a function over a specific range of x values?
147 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Erica Dawn Miller
am 23 Mär. 2021
Beantwortet: William
am 23 Mär. 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 Kommentare
Akzeptierte Antwort
William
am 23 Mär. 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!