Info

此问题已关闭。 请重新打开它进行编辑或回答。

How do I correctly plot this function?

3 次查看(过去 30 天)
Ethan Hoang
Ethan Hoang 2020-11-19
关闭: MATLAB Answer Bot 2021-8-20
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 个评论
Ethan Hoang
Ethan Hoang 2020-11-19
I tried what you suggested out and it worked. Thank you very much!

回答(0 个)

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by