Question
I am not getting the correct output. For velocity, I am getting 3 answers instead of 5, and for the second row, I am getting
I am not getting the correct output. For velocity, I am getting 3 answers instead of 5, and for the second row, I am getting 4 answers instead of 5. The output needs to be in a 5x5 matrix. My code is below
Write an M-file that computes the velocity for each of these channels. Enter these values into a matrix where each column represents a parameter and each row represents a channel. Have the M-file display the input data along with the computed velocity in tabular form where velocity is the fifth column. Include headings on the table to label the columns.
function M = Chapra_Problem_3p9(A)
%% Input
% -----
% A: Parameter Matrix (5 rows, 4 columns) where each row represents a channel and
% each column represents a parameter.
% (1) first column: roughness coefficient-----n
% (2) second column: channel slope------------S
% (3) third column: width (m)-----------------B
% (4) fourth column: depth (m)----------------H
%
%% Output
% ------
% M: Output Matrix(5 rows, 5 columns), a matrix that includes input data along with the
% computed velocity. The input data (matrix A) should occupy the first four columns,
% and velocity is the fifth column.
%
%% Write your code here.
M(:,5)=(sqrt(A(:,2))./A(:,1)).*((A(:,3).*A(:,4))./(A(:,3)+2*A(:,4))).^(2/3);
fprintf(' n S B H U ');
fprintf('%8.3f%8.4f%10.2f%10.2f%10.4f ',M');
end
Manning's equation can be used to compute the velocity of water in a rectangular open channel: 1l 0.036 0.020 0.015 0.030 0.022 0.0001 0.0002 0.0012 0.0007 0.0003 10 8 20 25 15 2 2.6 where U= velocity (m/s), S-channel slope, n = roughness coefficient, B available for five channels: width (m), and H= depth (m). The following data are
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started