When I run the following script, Octave only calculates and shows velocity in the message box.
total=0
choice=menu(' Welcome to Group 8 Open Channel Hydraulic Calculator click continue to start',' continue');
a=menu(' Please choose unit system', 'SI Units','U.S. Customary Units');
if a==1
choice= menu ('Please choose shape of the channel', 'Rectangle', 'Triangle','Trapezoid');
if (choice==1)
prompt= {'channel top width,b (meter)',' Channel depth,y(meter)','Channel height,h(meter)','Channel length,L(meter)', 'Mannings coefficient,n'};
dlg_title='Please insert channel dimension'
num_lines=1;
answer= inputdlg(prompt, dlg_title,num_lines);
top_width=str2double(answer{1});
channel_depth= str2double(answer{2});
channel_height=str2double(answer{3});
channel_length=str2double(answer{4});
n=str2double(answer{5});
Area= top_width*channel_depth;
Wetted_Perimeter= top_width+2*channel_depth;
Hydraulic_Radius= Area/Wetted_Perimeter;
K=1.00;
Slope= channel_height/channel_length;
b=menu('Please choose formula', 'Chezy Formula', 'Mannings Formula');
if(b==1)
velocity= (1/n)*Hydraulic_Radius^(1/6)*sqrt(Hydraulic_Radius*Slope);
elseif (b==2)
velocity=(K/n)*(Hydraulic_Radius)^(2/3)*sqrt(Slope);
endif
flow_rate= velocity*Area;
elseif (choice==2)
prompt= {'pitch,z (meter)',' Channel depth,y(meter)','Channel height,h(meter)','Channel length,L(meter)', 'Mannings coefficient'};
dlg_title='Please insert channel dimension'
num_lines=1;
answer= inputdlg(prompt, dlg_title,num_lines);
pitch=str2double(answer{1});
channel_depth= str2double(answer{2});
channel_height=str2double(answer{3});
channel_length=str2double(answer{4});
n=str2double(answer{5});
Area= pitch*(channel_depth^2);
Wetted_Perimeter= 2*channel_depth*((1+pitch^2)^(1/2));
Hydraulic_Radius= Area/Wetted_Perimeter;
K=1.00;
Slope= channel_height/channel_length;
b=menu('Please choose formula', 'Chezy Formula', 'Mannings Formula');
if(b==1)
velocity= (1/n)*Hydraulic_Radius^(1/6)*sqrt(Hydraulic_Radius*Slope);
elseif (b==2)
velocity=(K/n)*(Hydraulic_Radius)^(2/3)*sqrt(Slope);
endif
flow_rate= velocity*Area;
elseif(choice==3)
prompt= {'pitch,z (meter)','Bottom width,b(meter)', 'Channel depth,y(meter)','Channel height,h(meter)','Channel length,L(meter)', 'Mannings coefficient'};
dlg_title='Please insert channel dimension'
num_lines=1;
answer= inputdlg(prompt, dlg_title,num_lines);
pitch=str2double(answer{1});
bottom_width=str2double(answer{2});
channel_depth= str2double(answer{3});
channel_height=str2double(answer{4});
channel_length=str2double(answer{5});
n=str2double(answer{6});
Area= (bottom_width+pitch*(channel_depth))*channel_depth;
Wetted_Perimeter= bottom_width+2*channel_depth*((1+pitch^2)^(1/2));
Hydraulic_Radius= Area/Wetted_Perimeter;
K=1.00;
Slope= channel_height/channel_length;
b=menu('Please choose formula', 'Chezy Formula', 'Mannings Formula');
if(b==1)
velocity= (1/n)*sqrt(Hydraulic_Radius*Slope);
elseif (b==2)
velocity=(K/n)*(Hydraulic_Radius)^(2/3)*sqrt(Slope);
endif
flow_rate= velocity*Area;
endif
else a==2
choice= menu ('Please choose shape of the channel', 'Rectangle', 'Triangle','Trapezoid');
if (choice==1)
prompt= {'channel top width,b (ft)',' Channel depth,y(ft)','Channel height,h(ft)','Channel length,L(ft)', 'Mannings coefficient,n'};
dlg_title='Please insert channel dimension'
num_lines=1;
answer= inputdlg(prompt, dlg_title,num_lines);
top_width=str2double(answer{1});
channel_depth= str2double(answer{2});
channel_height=str2double(answer{3});
channel_length=str2double(answer{4});
n=str2double(answer{5});
Area= top_width*channel_depth;
Wetted_Perimeter= top_width+2*channel_depth;
Hydraulic_Radius= Area/Wetted_Perimeter;
K=1.49;
Slope= channel_height/channel_length;
b=menu('Please choose formula', 'Chezy Formula', 'Mannings Formula');
if(b==1)
velocity= (1/n)*Hydraulic_Radius^(1/6)*sqrt(Hydraulic_Radius*Slope);
elseif (b==2)
velocity=(K/n)*(Hydraulic_Radius)^(2/3)*sqrt(Slope);
endif
flow_rate= velocity*Area;
elseif (choice==2)
prompt= {'pitch,z (meter)',' Channel depth,y(meter)','Channel height,h(meter)','Channel length,L(meter)', 'Mannings coefficient'};
dlg_title='Please insert channel dimension'
num_lines=1;
answer= inputdlg(prompt, dlg_title,num_lines);
pitch=str2double(answer{1});
channel_depth= str2double(answer{2});
channel_height=str2double(answer{3});
channel_length=str2double(answer{4});
n=str2double(answer{5});
Area= pitch*(channel_depth^2);
Wetted_Perimeter= 2*channel_depth*((1+pitch^2)^(1/2));
Hydraulic_Radius= Area/Wetted_Perimeter;
K=1.49;
Slope= channel_height/channel_length;
b=menu('Please choose formula', 'Chezy Formula', 'Mannings Formula');
if(b==1)
velocity= (1/n)*Hydraulic_Radius^(1/6)*sqrt(Hydraulic_Radius*Slope);
elseif (b==2)
velocity=(K/n)*(Hydraulic_Radius)^(2/3)*sqrt(Slope);
endif
flow_rate= velocity*Area;
elseif(choice==3)
prompt= {'pitch,z (meter)','Bottom width,b(meter)', 'Channel depth,y(meter)','Channel height,h(meter)','Channel length,L(meter)', 'Mannings coefficient'};
dlg_title='Please insert channel dimension'
num_lines=1;
answer= inputdlg(prompt, dlg_title,num_lines);
pitch=str2double(answer{1});
bottom_width=str2double(answer{2});
channel_depth= str2double(answer{3});
channel_height=str2double(answer{4});
channel_length=str2double(answer{5});
n=str2double(answer{6});
Area= (bottom_width+pitch*(channel_depth))*channel_depth;
Wetted_Perimeter= bottom_width+2*channel_depth*((1+pitch^2)^(1/2));
Hydraulic_Radius= Area/Wetted_Perimeter;
K=1.49;
Slope= channel_height/channel_length;
b=menu('Please choose formula', 'Chezy Formula', 'Mannings Formula');
if(b==1)
velocity= (1/n)*sqrt(Hydraulic_Radius*Slope);
elseif (b==2)
velocity=(K/n)*(Hydraulic_Radius)^(2/3)*sqrt(Slope);
endif
flow_rate= velocity*Area;
endif
end
i = msgbox(['velocity =' num2str(velocity)],['flow rate=' num2str(flow_rate)]);
I expected the flow rate to be calculated and displayed along with the velocity in the message box, are there any ways to repair/locate/correct the mistake? Perhaps the flow rate should be placed before endif
(?). The code included is cut for the a==2
.