How to graph separate functions from a loop and find their max's?

1 vue (au cours des 30 derniers jours)
Danielle Guariglia
Danielle Guariglia le 20 Avr 2021
so i have a function that i need to change one variable a few different times.
I used a for loop and got a few different function outputs, which is what i want.
But i need to plot each one of those functions and find the absolute max on each one as well. I know it will be loops within loops i am just not sure how to call up each individual funtion to graph and then evaluate.
syms t
ymax = 0;
dt = .5;
for w = 4:dt:7
x = (4/(-w^2+36))*cos(6*t) + (2/3)*sin(6*t) - (4/(-w^2+36))*cos(w*t)
end
these are the functions i get in the command window
x =
cos(6*t)/5 - cos(4*t)/5 + (2*sin(6*t))/3
x =
(16*cos(6*t))/63 - (16*cos((9*t)/2))/63 + (2*sin(6*t))/3
x =
(4*cos(6*t))/11 - (4*cos(5*t))/11 + (2*sin(6*t))/3
x =
(16*cos(6*t))/23 - (16*cos((11*t)/2))/23 + (2*sin(6*t))/3
x =
NaN
x =
(16*cos((13*t)/2))/25 - (16*cos(6*t))/25 + (2*sin(6*t))/3
x =
(4*cos(7*t))/13 - (4*cos(6*t))/13 + (2*sin(6*t))/3
>>

Réponses (1)

Aghamarsh Varanasi
Aghamarsh Varanasi le 23 Avr 2021
Hi,
You can use the 'fplot' function to plot a function or expression. To calculate the local maxima or local minima of a function, you can refer to this documentation page.
Hope this helps

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by