This is my code to create a function. I have looked over many of the other questions regarding the max and min of a function and I keep getting error codes for max function and get function. This is my basic function:
f = @(r) (150.*(((1 + r).^36)-1) - 4500.*(r.*(1 + r).^36));
t = fplot(f,[0.0001 0.02]);
t
I have tried:
y = get(t,'YData');
imin = find(min(y) == y);% find the index of the min and max
imax = find(max(y) == y);
and it does not work. Any help is appreciated! Thank you!

 채택된 답변

Stephan
Stephan 2019년 10월 21일

0 개 추천

f = @(r) (150.*(((1 + r).^36)-1) - 4500.*(r.*(1 + r).^36));
t = fplot(f,[0.0001 0.02]);
high = max(t.YData)
low = min(t.YData)

댓글 수: 3

KYLE ALVAREZ
KYLE ALVAREZ 2019년 10월 21일
Thank you! One more questions if it is no problem, how would I put that as a point on the graph? I am new to MATLAB and have this code so far but cannot seem to put the hard point on it.
text(0.004,1,"Y Maximum = 2.592")
text(0.014,-25,"Y Minimum = -27.6068")
f = @(r) (150.*(((1 + r).^36)-1) - 4500.*(r.*(1 + r).^36));
t = fplot(f,[0.0001 0.02]);
[high, idh] = max(t.YData);
[low, idl] = min(t.YData);
hold on
scatter([t.XData(idl), t.XData(idh)], [low, high], 'or')
text(0.004,1,"Y Maximum = 2.592")
text(0.014,-25,"Y Minimum = -27.6068")
hold off
KYLE ALVAREZ
KYLE ALVAREZ 2019년 10월 22일
Thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Graphics Performance에 대해 자세히 알아보기

질문:

2019년 10월 21일

댓글:

2019년 10월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by