
Plotting error: I am trying to plot the equations and the output should be as shown but its not
3 ビュー (過去 30 日間)
古いコメントを表示
beta=5;
t1=0:0.1:4.4;
alfa=2.*beta/(beta+1);
E1=-alfa .*exp(-tau1.*t1) + alfa
plot(t1,E1);
gamma=alfa.*(2-exp(-tau1));
tau1=2
tau2=2.4;
t2=4.4:0.01:5;
E2=(gamma.*exp(-(0.4).*t2))-(5/3);
plot(t2,E2);


What am I doing wrong? The fist equation I can plot as it is, but not the second E2. which is the part between t1 and t2 on the plot.
0 件のコメント
採用された回答
Stephan
2019 年 1 月 2 日
編集済み: Stephan
2019 年 1 月 3 日
Hi,
try:
% Constants
beta=5;
alfa = 2.*beta/(beta+1);
tau1=2;
tau2=2.4;
gamma=alfa.*(2-exp(-tau1));
% Time frames
t1=0:0.01:tau1;
t11 = tau1:0.01:4.4;
t2 = tau1:0.01:tau2;
t22 = tau2:0.01:4.4;
t3 = tau2:0.01:4.4;
% Part A
EeA = @(t) -alfa .*exp(-t) + alfa;
EeA1 = EeA(t1);
EeA2 = EeA(t11);
plot(t1,EeA1,'-b',t11,EeA2,'--g','lineWidth',2)
hold on
Ee1 = EeA(tau1);
scatter(tau1,Ee1,'ro','lineWidth',2,'MarkerFaceColor','r')
% Part B
EeB = @(t) gamma.*exp(-(t-tau1)) - alfa;
EeB1 = EeB(t2);
EeB2 = EeB(t22);
plot(t2, EeB1,'-b',t22, EeB2,'--g','lineWidth',2)
Ee2 = EeB(tau2);
scatter(tau2,Ee2,'ro','lineWidth',2,'MarkerFaceColor','r')
% Part C
EeC = @(t) Ee2.*exp(-(t3-tau2));
EeC1 = EeC(t3);
plot(t3, EeC1,'-b','lineWidth',2)
hold off
results in:

This version should be correct.
Best regards
Stephan
5 件のコメント
その他の回答 (1 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
