MATLAB: Hello, i need to plot a graph (n) number of times with an offset of a known number between each line on the graph, note all the lnes should be parallel on the same graph but repeated

plot

clear,clc,clf
format short
Q=3.3;
%gamma=8.43 kN/m3 = 859.62076503 Kg/m3 (*1000/9.81)
rouh=859.62076503;
g=9.81;
Gamma=(rouh.*g);
Zs=0;
Ze=0;
L=1285000;
Ks=(0.000045);
Er=(1.*10.^-8);
viscosity=(3.83.*10.^-3);
% material grade X70
strength= 482000000;
%API 5L
D5L=[12.75*0.0254 14*0.0254 16*0.0254 18*0.0254 20*0.0254 22*0.0254 24*0.0254 26*0.0254 28*0.0254 30*0.0254 32*0.0254 34*0.0254 36*0.0254 38*0.0254 40*0.0254 42*0.0254 44*0.0254 46*0.0254 48*0.0254 52*0.0254 56*0.0254 60*0.0254 64*0.0254 68*0.0254 72*0.0254 76*0.0254 80*0.0254]
V5L=((4.*Q)./(pi.*D5L.^2));
V=V5L(V5L > 1 & V5L < 4.5)
Do=((4.*Q)./(pi.*V)).^(0.5)
Re=(V.*Do./viscosity)
Fo=0.01;
for I=0:1:10^6;
Fn=(1./(-4.*log10((Ks./(3.71.*Do))+((1.26)./(Re.*sqrt(Fo)))))).^2;
E=abs((Fn-Fo)/Fn);
if E<=Er;
Fn=Fn(end),display(E),break,
end
if E>Er;
Fo=Fn;
end
end
Hloss=((Fn.*L.*Q.^2)./(12.*Do.^5))
Hpump=Hloss+Ze-Zs
PRESSURE=rouh.*g.*Hpump.*10.^(-5)
numberofpumps=ceil(PRESSURE./90)
pressureperpump=(PRESSURE./numberofpumps)
Distancebetweeneachpump=L./numberofpumps
%calculating Hloss every 128500M
n=numberofpumps
LC=1:128500:1285000;
for i=1:1:length(LC);
HlossN=((Fn.*LC(i).*Q.^2)./(12.*Do.^5))
TEL(i,:)=(Hpump-HlossN+Zs)
HGL(i,:)=(TEL(i,:)-((V.^2)./(2.*g)))
PE=Gamma.*(HGL-Ze)
T=((PE(i).*Do)./(2.*strength))
end
n=numberofpumps
for ii=1:1:length(Do)
subplot(4,4,ii)
plot(LC,TEL(:,ii))
hold on
plot(LC,HGL(:,ii))
xlabel('LC')
ylabel('HGL & TEL')
end
….
please note that the the number of lines that should be available per graph is the (number of pumps)–line 37
and each line should be (distance between each pump)–line 39 away from the line before it.
it should look like that

Best Answer

You don't want to use subplot. Look into the hold command.