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.

채택된 답변

Stephan
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:
plot_new.PNG
This version should be correct.
Best regards
Stephan
  댓글 수: 5
Stephan
Stephan 2019년 1월 23일
편집: Stephan 2019년 1월 23일
ZD is not a scalar - it is a row vevtor:
This is why you get the error. Look also at the content of ZD - it is all Inf

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

madhan ravi
madhan ravi 2019년 1월 2일
Define them as piecewise curves and then plot them.

카테고리

Help CenterFile Exchange에서 Physics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by