How do I correctly plot this function?
Informazioni
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
Mostra commenti meno recenti
Hello, I'm trying to generate a plot with the x I found, which was 92, that shows a curve that is just below the limit, which is 50. I can't seem to get a smooth plot/curve. I think it's because I might be plotting the wrong data. Any ideas on what I'm doing wrong? The rest of the code should be correct, it's just the plotting towards the end. Thank you!
function y = glucose_response_f(tt,K,tau,x)
syms t s
u = 5*((heaviside(t)-heaviside(t-5))+(heaviside(t-x)-heaviside(t-(x+5))));
U = laplace(u);
T = K/(s+1/tau)^2;
yt = ilaplace(T*U);
pretty(yt);
y = subs(yt,{t},tt);
disp('')
disp(['y=' num2str(double(y)) '[%]'])
end
%Command window
tt = [0 25 50 75 100 125 150 175 200];
K=0.1;
tau=40;
x=92;
y = glucose_response_f(tt,K,tau,x);
%Ans
heaviside(t - 5) (1600 #3 + 40 #3 (t - 5) - 1600) / t \ / t \
------------------------------------------------- - t exp| - -- | 20 - exp| - -- | 800
2 \ 40 / \ 40 /
heaviside(t - 92) (1600 #2 + 40 #2 (t - 92) - 1600)
- ---------------------------------------------------
2
heaviside(t - 97) (1600 #1 + 40 #1 (t - 97) - 1600)
+ --------------------------------------------------- + 800
2
where
/ 97 t \
#1 == exp| -- - -- |
\ 40 40 /
/ 23 t \
#2 == exp| -- - -- |
\ 10 40 /
/ 1 t \
#3 == exp| - - -- |
\ 8 40 /
y=0 31.9969 36.2006 29.5863 33.179 49.8597 43.87 32.6788 22.4144[%]
plot(tt,y)
4 Commenti
Are you talking about this? If so then you are limited by the small number of tt values.
%Command window
tt = [0 25 50 75 100 125 150 175 200];
K=0.1;
tau=40;
x=92;
y = glucose_response_f(tt,K,tau,x);
plot(tt, y)
function y = glucose_response_f(tt,K,tau,x)
syms t s
u = 5*((heaviside(t)-heaviside(t-5))+(heaviside(t-x)-heaviside(t-(x+5))));
U = laplace(u);
T = K/(s+1/tau)^2;
yt = ilaplace(T*U);
% pretty(yt);
y = subs(yt,{t},tt);
disp('')
disp(['y=' num2str(double(y)) '[%]'])
end
Ethan Hoang
il 19 Nov 2020
Walter Roberson
il 19 Nov 2020
Add more values to the tt list.
Ethan Hoang
il 19 Nov 2020
Risposte (0)
Questa domanda è chiusa.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
