% Example 12-5: Water flow in a river % Width of the river w = 8; % Data measured % d Day of year % h Height of water % speed Velocity of water d = [1 32 60 91 121 152 182 213 244 274 305 335 366]; h = [2 2.1 2.3 2.4 3.0 2.9 2.7 2.6 2.5 2.3 2.2 2.1 2.0]; speed = [2 2.2 2.5 2.7 5 4.7 4.1 3.8 3.7 2.8 2.5 2.3 2 ]; % Flow rate Q Q = speed.*w.*h; % Integrate with trapz using the data to find % volume in cubic meters Vol = 60*60*24*trapz(d, Q) % Plot flow rate over the time interval plot(d, Q) xlabel('Day'); ylabel('Flow Rate (m^3/s)');