How do I correctly plot this function?
情報
この質問は閉じられています。 編集または回答するには再度開いてください。
古いコメントを表示
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 件のコメント
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
2020 年 11 月 19 日
Walter Roberson
2020 年 11 月 19 日
Add more values to the tt list.
Ethan Hoang
2020 年 11 月 19 日
回答 (0 件)
この質問は閉じられています。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
