Ignoring a set of values

2 views (last 30 days)
Ethan Boyce
Ethan Boyce on 26 Aug 2020
Commented: Ethan Boyce on 26 Aug 2020
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}))

Accepted Answer

esat gulhan
esat gulhan on 26 Aug 2020
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 Comment
Ethan Boyce
Ethan Boyce on 26 Aug 2020
Wooow, another point to me for making things much more complex than they need to be. Thank you!

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!