Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

How do I correctly plot this function?

5 Ansichten (letzte 30 Tage)
Ethan Hoang
Ethan Hoang am 19 Nov. 2020
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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 Kommentare
Walter Roberson
Walter Roberson am 19 Nov. 2020
Add more values to the tt list.
Ethan Hoang
Ethan Hoang am 19 Nov. 2020
I tried what you suggested out and it worked. Thank you very much!

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by