matlabman
Civil/Environmental
- Apr 30, 2010
- 3
hi,
I am relatively new to matlab and have created a code for a problem using loops however I want to display the results of each iteration as a graph. I can plot as dots by using hold on/hold off - effectively just overlaying numerous single point graphs. does anyone know how I can get the results to display as a continuos line graph.
the code I have is:
%Inputs
Hi=8;
Qin=xlsread('data')
A=223453;
Hd=18;
Qout=5.26*24*60*60/1000
%Calcs
V=Hi*A/1000
Vmax=A*Hd/1000
%reset ii (index value)
if V>=0.9*Vmax
ii=1
else ii=0
end
while ii<155
if V<0.9*Vmax
ii=ii+1;
end
hold on
plot (ii,V)
if V>=0.9*Vmax
while V>0.7*Vmax && ii
ii=ii+1;
if V+Qin(ii)-Qout*3 > Vmax
V=Vmax
else V=V+Qin(ii)-Qout*3
end
end
elseif V>=0.3*Vmax
V=V+Qin(ii)-Qout
if V>=Vmax
V=Vmax
end
else
V=V+Qin(ii)
while V<0.5*Vmax && ii<155
ii=ii+1;
if Qin(ii)> (Vmax-V)
V=Vmax
else V=V+Qin(ii)
end
end
if V<0.9*Vmax
end
end
end
hold off
I am relatively new to matlab and have created a code for a problem using loops however I want to display the results of each iteration as a graph. I can plot as dots by using hold on/hold off - effectively just overlaying numerous single point graphs. does anyone know how I can get the results to display as a continuos line graph.
the code I have is:
%Inputs
Hi=8;
Qin=xlsread('data')
A=223453;
Hd=18;
Qout=5.26*24*60*60/1000
%Calcs
V=Hi*A/1000
Vmax=A*Hd/1000
%reset ii (index value)
if V>=0.9*Vmax
ii=1
else ii=0
end
while ii<155
if V<0.9*Vmax
ii=ii+1;
end
hold on
plot (ii,V)
if V>=0.9*Vmax
while V>0.7*Vmax && ii
ii=ii+1;
if V+Qin(ii)-Qout*3 > Vmax
V=Vmax
else V=V+Qin(ii)-Qout*3
end
end
elseif V>=0.3*Vmax
V=V+Qin(ii)-Qout
if V>=Vmax
V=Vmax
end
else
V=V+Qin(ii)
while V<0.5*Vmax && ii<155
ii=ii+1;
if Qin(ii)> (Vmax-V)
V=Vmax
else V=V+Qin(ii)
end
end
if V<0.9*Vmax
end
end
end
hold off