Trying to get the 2nd functions to plot to the right of the first.

조회 수: 4 (최근 30일)
Christopher Jarrett
Christopher Jarrett 2021년 2월 18일
댓글: Christopher Jarrett 2021년 2월 18일
format long
r=1000;
c=100*(10^(-6));
rc=r*c;
vs=4;
tf=2;
%% 2 exact solution for charging and discharging
% for charging
ti=0;
dt=0.01;
t1= ti:dt:tf;
vcap1 = vs*(1-exp((-t1)/(rc)));
plot(t1,vcap1)
hold on;
ti2(1)=tf;
tf2=10;
t2 = ti2:dt:tf2;
n =(tf-ti)/dt;
o = 1000-n;
vcap2 = zeros(o+1,1);
vcap2(1) = vcap1(end);
tc = zeros(o+1,1);
tc(1) = -rc*log((vcap2(1))/vs);
%= vs*exp(-tc(i+1)/(rc));
for i = 1:o
t2(i+1) = t2(i)+ dt;
vcap2(i+1)=vcap2(i)-dt;
tc(i+1) = -rc*log((vcap2(i+1))/vs);
end
plot(tc,vcap2)
  댓글 수: 1
the cyclist
the cyclist 2021년 2월 18일
What is your question? We cannot read your mind, so please explain everything we need to know, so we can help.

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

답변 (1개)

Cris LaPierre
Cris LaPierre 2021년 2월 18일
Your X values determine where your plots appear horizontally. Adjust the X values of your second plot command to start at the max X value of your first plot.
plot(max(t1)+tc,vcap2)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by