MATLAB: Doesnt the code show the ploted lines from the answers

MATLAB and Simulink Student Suiteplotting

clc, close, clear all;
dx=zeros; %Initialize all the arrays
h=zeros;
h1=35; %Initial head
g=9.81;
yc=4*h1/9; %Depth at x=0
q=(8/27)*sqrt(g*h1^3); %Discharge at x=0
vc=(2/3)*sqrt(g*h1); %Velocity at x=0
Lim1=round(sqrt(h1*g)); %Set validity limits m/s
Lim2=round(2*Lim1); %Set validity limits m/s
t=[50:50:450]; %Simulation time
nt=length(t);
dxx=[-Lim1:1:Lim2]; %Create distance time m/s
nr=length(dxx);
Hout=zeros(nr,nt); %Initialize used for plotting
Dlen=zeros(nr,nt); %Initialize used for plotting
for j=1:nt % time loop
for i=1:nr %x loop
dx(i)=dxx(i)*t(j); %Convert m/s to m distance
c1=dxx(i)/(3*sqrt(g)); %dxx=x/t=Lim1-Lim2
hh=0.6667*sqrt(h1)-c1;
h(i)=hh^2;
Hout(i,j)=h(i); %Used for plotting
Dlen(i,j)=dx(i); %Used for plotting
end
end
%Create plot legend
tx=t(:); %Convert row vector to column vector
Lxx=num2str(tx); %Legend text
Hout=zeros(nr,nt); %used for plotting
Dlen=zeros(nr,nt); %used for plotting
plot(Dlen,Hout(1:nr,:))
xlabel('Distance (m)');
ylabel('Water depth (m)');
grid on;
title('Wave profile due to dam failure');
legend(Lxx);

Best Answer

You set them all to 0 before you plot them:
%Create plot legend
tx=t(:); %Convert row vector to column vector
Lxx=num2str(tx); %Legend text
Hout=zeros(nr,nt); %used for plotting % ← HERE
Dlen=zeros(nr,nt); %used for plotting % ← AND HERE
plot(Dlen,Hout(1:nr,:))
xlabel('Distance (m)');
ylabel('Water depth (m)');
grid on;
title('Wave profile due to dam failure');
legend(Lxx);
Comment those lines out (or better yet remove them) and the lines magically appear!