%Simple discharge script
%Constant and array values for each variable below, remove comment markers
%to activate variable.
width = 300; %in feet
%width = 0:1:200;
depth = 25; %in feet
%depth = 0:.125:25;
%n = 0.02; %mannings n for roughness
n = 0.01:.0002:.05;
slope = 0.001; %slope along channel
%slope = 0:0.001:0.2;
verbose = 0; %1 if you want to see written output, 0 otherwise

WettedPerimeter = width + 2.*depth;
R = (width.*depth)./WettedPerimeter;
velocity = (1.49./n).*(R.^(2./3)).*slope.^((1./2));

Q = velocity.*width.*depth;

if verbose ==1
fprintf('width = %.1f feet and depth = %.1f feet\n', width, depth)
fprintf('Wetted Perimeter = %.1f feet and R = %.1f feet\n', WettedPerimeter, R)
fprintf('velocity = %.1f feet/sec\n', velocity)
fprintf('discharge = %.1f cubic feet/sec\n', Q)
end

figure(1)
clf
plot(velocity,slope,'-b')
title('Velocity vs Channel Slope')
xlabel('Velocity')
ylabel('Channel Slope')

figure(2)
clf
plot(Q,slope,'-b')
title('Discharge vs Channel Slope')
xlabel('Discharge')
ylabel('Channel Slope')

figure(3)
clf
plot(velocity,R,'-r')
title('Velocity vs Hydraulic Radius')
xlabel('Velocity')
ylabel('Hydraulic Radius')

figure(4)
clf
plot(velocity,n,'-g')
title('Velocity vs Channel Roughness')
xlabel('Velocity')
ylabel('Channel Roughness')

figure(5)
clf
plot(Q,n,'-c')
title('Discharge vs Channel Roughness')
xlabel('Discharge')
ylabel('Channel Roughness')