i have a problem connecting 5 dots together using the plot fuction. i should have two parrallel lines but i get a blank sheet

7 vues (au cours des 30 derniers jours)
clear,clc,clf
format long
Q=0.03;
rouh=847;
g=9.81;
Gamma=(rouh.*g);
Zs=0;
Ze=0;
L=500;
Ks=(6*10.^-5);
viscosity=(1.1*10.^-6);
V=1.34:0.5:4.5
for I=1
D=sqrt(((4.*Q))./(V.*pi))
end
Re=(V.*D./viscosity);
Er=(1.*10.^-8);
Fo=0.01;
for I=0:1:10^6;
Fn=(1./(-4.*log10((Ks./(3.71.*D))+((1.26)./(Re.*sqrt(Fo)))))).^2;
E=abs((Fn-Fo)/Fn);
if E<=Er;
display(Fn),display(E),break,
end
if E>Er;
Fo=Fn;
end
end
Hloss=((Fn.*L.*Q.^2)./(12.*D.^5))
Hpump=Hloss
%calculating Hloss every 100M
Hloss=((Fn.*L.*Q.^2)./(12.*D.^5))
Hpump=Hloss
%calculating Hloss every 100M
for HLC=(1:100:500);
r0=HLC
HlossN=((Fn.*HLC.*Q.^2)./(12.*D.^5))
TEL=(Hpump-HlossN+Zs)
r1 = TEL(:,1)
HGL=(TEL-((V.^2)./2.*g))
r2 = HGL(:,1)
plot(r0,r1,'LineStyle', '--')
hold on
plot(r0,r2,'LineStyle', '--')
end

Réponses (1)

Cris LaPierre
Cris LaPierre le 8 Déc 2018
Modifié(e) : Cris LaPierre le 8 Déc 2018
You plot command is inside a for-loop that runs 5 times (HLC == 1, 101, 201, 301, 401). Placing it here means it will plot the data one point at a time (not connecting them). Nothing is appearing becaues you have only specified LineStyle and no Marker style. Since no line appears when you plot a single point, the result is you see nothing in the plot. Try changing your plot command to this:
plot(r0,r1,'o','LineStyle', '--')
If you want the plot command to automatically connect the lines, first build a vector with all the numbers and then plot (outside the for loop).
  2 commentaires
omar mahallawy
omar mahallawy le 9 Déc 2018
unfortunatly i already tried the new plot with the linestyle and it only shows me the dots (unconnected)
clear,clc,clf
format long
Q=0.03;
rouh=847;
g=9.81;
Gamma=(rouh.*g);
Zs=0;
Ze=0;
L=500;
Ks=(6*10.^-5);
viscosity=(1.1*10.^-6);
V=1.34:0.5:4.5
for I=1
D=sqrt(((4.*Q))./(V.*pi))
end
Re=(V.*D./viscosity);
Er=(1.*10.^-8);
Fo=0.01;
for I=0:1:10^6;
Fn=(1./(-4.*log10((Ks./(3.71.*D))+((1.26)./(Re.*sqrt(Fo)))))).^2;
E=abs((Fn-Fo)/Fn);
if E<=Er;
display(Fn),display(E),break,
end
if E>Er;
Fo=Fn;
end
end
Hloss=((Fn.*L.*Q.^2)./(12.*D.^5))
Hpump=Hloss
%calculating Hloss every 100M
Hloss=((Fn.*L.*Q.^2)./(12.*D.^5))
Hpump=Hloss
%calculating Hloss every 100M
for HLC=(1:100:500);
HlossN=((Fn.*HLC.*Q.^2)./(12.*D.^5))
TEL=(Hpump-HlossN+Zs)
TEL1 = TEL(:,1);
TEL2 = TEL(:,2);
TEL3 = TEL(:,3);
TEL4 = TEL(:,4);
TEL5 = TEL(:,5);
TEL6 = TEL(:,6);
TEL7 = TEL(:,7);
HGL=(TEL-((V.^2)./2.*g))
HGL1 = HGL(:,1);
HGL2 = HGL(:,2);
HGL3 = HGL(:,3);
HGL4 = HGL(:,4);
HGL5 = HGL(:,5);
HGL6 = HGL(:,6);
HGL7 = HGL(:,7);
subplot(3,3,1)
plot(HLC,TEL1,'+b','LineStyle', '--')
hold on
plot(HLC,HGL1,'+b','LineStyle', '--')
subplot(3,3,2)
plot(HLC,TEL2,'+c','LineStyle', '--')
hold on
plot(HLC,HGL2,'+c','LineStyle', '--')
subplot(3,3,3)
plot(HLC,TEL3,'+m','LineStyle', '--')
hold on
plot(HLC,HGL3,'+m','LineStyle', '--')
subplot(3,3,4)
plot(HLC,TEL4,'+c','LineStyle', '--')
hold on
plot(HLC,HGL4,'+c','LineStyle', '--')
subplot(3,3,5)
plot(HLC,TEL5,'+k','LineStyle', '--')
hold on
plot(HLC,HGL5,'+k','LineStyle', '--')
subplot(3,3,6)
plot(HLC,TEL6,'+g','LineStyle', '--')
hold on
plot(HLC,HGL6,'+g','LineStyle', '--')
subplot(3,3,7)
plot(HLC,TEL7,'+r','LineStyle', '--')
hold on
plot(HLC,HGL7,'+r','LineStyle', '--')
end
Jan
Jan le 9 Déc 2018
Modifié(e) : Cris LaPierre le 11 Déc 2018
@omar: Cris has answered the question already and explained, that you have to create the vectors at first. See this example:
subplot(1, 2, 1, 'NextPlot', 'add');
for k = 1:10
plot(k, rand, 'o-');
end
subplot(1, 2, 2, 'NextPlot', 'add');
v = nan(1, 10);
for k = 1:10
v(k) = rand;
end
plot(1:10, v, 'o-');

Connectez-vous pour commenter.

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by