MATLAB: There is no line in the graph

graph

clc;
disp('==========================================================================================');
disp('= =');
disp('= PROGRAM PERANCANGAN TANGKI PENGADUK (MIXING) =');
disp('= =');
disp('==========================================================================================');
disp('');
disp('');
disp(' ===============================');
disp(' = Pilih Jenis Larutan =');
disp(' ===============================');
disp('=====================');
disp('=1. Larutan NaCl =');
disp('=2. Larutan C6H12O6 =');
disp('=====================');
pil=input ('Masukkan Pilihan larutan= ');
clc;
switch pil
case 1
disp(' ===================================');
disp(' = Larutan NaCl =');
disp(' ===================================');
n=input ('Masukkan kecepatan pengaduk (rps)= ');
d=input ('Masukkan diameter pengaduk (m)= ');
disp('==========================================================================================');
disp(' Densitas Kec. Pengaduk Diameter Pengaduk Viskositas NRe Jenis Aliran ');
disp(' (Kg/m^3) (Rps) (m) (Kg/Ms) ');
disp('==========================================================================================');
for a=n:2:10;
den=2160;
vis=0.94;
nre=(den*a*d)/vis;
if nre<2000
c='ALIRAN LAMINER';
elseif nre>2000 & nre<4000
c='ALIRAN TRANSISI';
else
c='ALIRAN TURBULEN';
end;
fprintf('%8.2f%13.2f%19.2f%18.2f%14.2f%18s\n',den,a,d,vis,nre,c);
end;
disp('');
disp('');
disp(' ===================================');
disp(' = Menghitung Power Tangki =');
disp(' ===================================');
p=input ('Input power (watt)= ');
disp('');
disp('=============================================================================================================');
disp(' Power Kec. Pengaduk Diameter Pengaduk Densitas Konstanta Gravitasi NRe power Number ');
disp('(Watt) (Rps) (m) (Kg/m^3) (Kg.m/N.S^2) (Kg.m^2/S^2) ');
disp('=============================================================================================================');
while n<=10
g=1;
Np=(n.^3*d.^3*den)/p*g;
fprintf('%8.2f%13.2f%19.2f%18.2f%14.2f%19.2f%18.2f\n',p,n,d,den,g,nre,Np);
n=n+2;
plot(Np,nre,'--r*','linewidth',2,'markeredgecolor','g');
hold on;
grid on;
set(gca,'fontsize',12);
title('Grafik Hubungan Nre Vs Power Number','fontweight','bold','fontsize',12);
xlabel('Power Number (Kg.m^2/S^2)');
ylabel('Nre');
end;
end;

Best Answer

"Why there is no line in my graph?"
Because you are plotting one scalar point on each loop iteration. This will NOT give a line:
for k = 1:10
plot(k,sqrt(k),'-*') % indivdual points does NOT plot a line!
end
If you want to plot a line, then you will need to store those scalar values in vectors, and plot the vectors after the loop. To plot lines you need to do something like this:
X = 1:10
Y = sqrt(X);
plot(X,Y,'-*') % plotting with vectors gives a line!
So basically before your loop you should preallocate some vectors, then inside the loop store your output values in the vectors, and then after the loop you plot the vectors.
Related Question