필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
Danielle Guariglia
Danielle Guariglia 2021년 4월 20일
답변: Aghamarsh Varanasi 2021년 4월 23일
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
>>

답변 (1개)

Aghamarsh Varanasi
Aghamarsh Varanasi 2021년 4월 23일
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

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by