Ignoring a set of values

2 ビュー (過去 30 日間)
Ethan Boyce
Ethan Boyce 2020 年 8 月 26 日
コメント済み: Ethan Boyce 2020 年 8 月 26 日
I need to ignore the second values returned for my subsequent functions. In other words, for the values of t_max, I need to keep 10.27 and ignore 129.72
close all
clear all
syms t b r;
%Profit equation
P = (200+b*t)*(0.65-0.01*r*t+0.00004*t^2)-0.45*t;
%Best time to sell
dPdt = simplify(vpa(diff(P, t)))
sym_t_max =simplify(vpa(solve(diff(P, t), t)))
t_max = simplify(subs(sym_t_max, {b, r}, {5,1}))
P_max = simplify(subs(P, {t,b,r}, {t_max, 5,1}))

採用された回答

esat gulhan
esat gulhan 2020 年 8 月 26 日
Try this
close all
clear all
syms t b r;
%Profit equation
P = (200+b*t)*(0.65-0.01*r*t+0.00004*t^2)-0.45*t;
%Best time to sell
dPdt = simplify(vpa(diff(P, t)));
sym_t_max =simplify(vpa(solve(diff(P, t), t)));
t_max = simplify(subs(sym_t_max, {b, r}, {5,1}));
P_max = simplify(subs(P, {t,b,r}, {t_max, 5,1}));
t_max(1)
P_max(1)
  1 件のコメント
Ethan Boyce
Ethan Boyce 2020 年 8 月 26 日
Wooow, another point to me for making things much more complex than they need to be. Thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by