Ignoring a set of values

3 visualizzazioni (ultimi 30 giorni)
Ethan Boyce
Ethan Boyce il 26 Ago 2020
Commentato: Ethan Boyce il 26 Ago 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}))

Risposta accettata

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

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by