Can't find the maximum on the graph of a function

5 ビュー (過去 30 日間)
Nabiha Hasan
Nabiha Hasan 2019 年 3 月 8 日
コメント済み: Nabiha Hasan 2019 年 3 月 8 日
Hello! I'm not sure how to answer this homework problem I have. I've gotten halfway through the code and have done an fplot, but I can't find anything on how to plot the max of an fplot/find the max of an fplot. The problem is below:
hw moore 6.7.png
This is my code so far:
t = [0:30];
h = height(t);
fplot(height(t),[0,30])
function h=height(t);
h=@(t) (-(9.8/2).*t.^2)+(125.*t)+500
end
Adding a max value just creates a huge error message, and I'm not sure why:
t = [0:30];
h = height(t);
fplot(height(t),[0,30])
[max_t,max_h]=max(height(t))
function h=height(t);
h=@(t) (-(9.8/2).*t.^2)+(125.*t)+500
end

採用された回答

KSSV
KSSV 2019 年 3 月 8 日
t = 0:30;
h = (-(9.8/2).*t.^2)+(125.*t)+500 ;
[val,idx] = max(h) ;
h_max = val ;
t_max = t(idx) ;
plot(t,h)
hold on
plot(t_max,h_max,'*r')
  3 件のコメント
madhan ravi
madhan ravi 2019 年 3 月 8 日
Why not?, the answer proposed did your homework perfectly.
Nabiha Hasan
Nabiha Hasan 2019 年 3 月 8 日
Yes, it definitely did. But I was wondering if there was any way to find the max of the function itself? When I used his code, it worked fine, but when I tried to find the max of the function height(t), it just told me it wasn't a numerical value.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Identification についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by