MATLAB Answers

represent a function in Matlab

28 views (last 30 days)
I don't understand the graph of this exponential function, it is look like a two line instead of an exponential, this is the code and the figure:
xo = 400;
yo = 7000;
x = 260;
y = 6954;
a = 0.5, b =0.4;
K = b*xo-a*yo;
t= 0:0.5:50
y = K./(exp((K*t)-(K*(log(b*xo/yo)/(-(K)))))-a);
figure
plot (t,y)

Accepted Answer

Steven Lord
Steven Lord on 1 Mar 2021
Let's look at your function symbolically.
xo = 400;
yo = 7000;
x = 260;
y = 6954;
a = 0.5; b =0.4;
K = b*xo-a*yo;
% t= 0:0.5:50
syms t
y = K./(exp((K*t)-(K*(log(b*xo/yo)/(-(K)))))-a);
vpa(y, 5)
ans = 
That exponential term is the exponential of a very large (in magnitude) negative number. It very quickly underflows to 0.
format longg
fun = @(t) exp(-3340*t-3.7785);
t = logspace(-9, 0, 10).';
results = table(t, fun(t), 'VariableNames', ["t", "fun(t)"])
results = 10x2 table
t fun(t) ______ _____________________ 1e-09 0.0228568748085117 1e-08 0.0228561877411816 1e-07 0.0228493182036898 1e-06 0.0227807362834381 1e-05 0.0221061373691749 0.0001 0.0163668063215704 0.001 0.000809980811568495 0.01 7.13809961741543e-17 0.1 2.01679308890843e-147 1 0
If we evaluated that at a symbolic value of 50, what's the value?
vpa(fun(sym(50)), 10)
ans = 
1.51544597e-72529
When you're talking about numbers that small you're not quite at the probability of a monkey typing Hamlet first try, but maybe one of Shakespeare's shorter plays? For most other intents and purposes, that value is 0.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!