Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part B and C the secong image is assign05.m clc, clear all %*****CONSTANT***** NUM_MONTHS = 12; FIRST_YEAR = 2013; LAST_YEAR = 2016; %*****INPUT***** months =

Part B and C image text in transcribed

the secong image is assign05.m

image text in transcribed

clc, clear all %*****CONSTANT***** NUM_MONTHS = 12; FIRST_YEAR = 2013; LAST_YEAR = 2016; %*****INPUT***** months = 1:NUM_MONTHS; years = FIRST_YEAR:LAST_YEAR; % read data file lake_powell = load( 'lake_powell.txt' ); % OR load lake_powell.txt % print with title and year column headings. fprintf(' Lake Powell Water Levels (in feet) ') fprintf('%8d ', years) fprintf(' ') % print contents of lake_powell for month = 1:NUM_MONTHS fprintf('%9.2f', lake_powell(month,:)) fprintf(' ') end % PART B ========================================================== fprintf(' PART B: Determine average elevation of water level for each year and overall average ') yearAve = mean(lake_powell); fprintf(' Average for Each Year (in feet) ') fprintf('%8d ', years) fprintf(' ') fprintf('%9.2f', yearAve) fprintf(' ') overallAve = mean(yearAve); fprintf(' Overall average: %.2f feet ', overallAve) % PART C ========================================================== fprintf(' PART C: Determine how many months of each year > overall average ') for year=1:length(years) over_average(year)=length(find(lake_powell(:,year)>overallAve)); end fprintf(' During %5.0f the lake was above average for %3.0f months ',... [years;over_average]) % PART D ========================================================== fprintf(' PART D: Determine and print average elevation of the water for each month ') monthly_average=mean(lake_powell'); table = [months;monthly_average]; fprintf(' Average elevation (in feet) of the water for each month ') fprintf(' Month Elevation ') fprintf(' %2d %9.2f ',table)

3.6801200e+003 3.6680500e+003 3.6542500e+003 3.6176100e+003

3.6784800e+003 3.6650200e+003 3.6510100e+003 3.6130000e+003

3.6772300e+003 3.6633500e+003 3.6486300e+003 3.6089500e+003

3.6764400e+003 3.6625600e+003 3.6467900e+003 3.6059200e+003

3.6767600e+003 3.6652700e+003 3.6448800e+003 3.6061100e+003

3.6821900e+003 3.6721900e+003 3.6429800e+003 3.6153900e+003

3.6828600e+003 3.6713700e+003 3.6375300e+003 3.6136400e+003

3.6811200e+003 3.6678100e+003 3.6308300e+003 3.6073200e+003

3.6787000e+003 3.6654500e+003 3.6271000e+003 3.6041100e+003

3.6769600e+003 3.6634700e+003 3.6255900e+003 3.6029200e+003

3.6749300e+003 3.6612500e+003 3.6239800e+003 3.6012400e+003

3.6715900e+003 3.6580700e+003 3.6216500e+003 3.5988200e+003

Program: assign06b.m REMOVE UNNECESSARY STATEMENTS FROM PREVIOUS PROGRAMS. INCLUDE APPROPRIATE COMMENTS Check the file ID to determine if the file is available. New commands fopen 0 fscanf Only print message if file is not available. Use nested for loops to read one water level value at a time into the lake powel matrix. lake-powell (month, year) = fscan f (filer, '", 1); nested for loops Continue to use fprintf O Use mean to determine the average elevation of the water level for sash year and the nt water level with overall average for the four-year period over which the data were collected. Print the yearly average vector and the overall average with labels as shown below. 2 decimal places Print year, month with 0 decimal places Align numbers under headings Use constant names Additional Problem Constants: (with unit comments) data file name Output: Average for Each Year (in feet) 2013 2015 2016 2014 3579.90 3585.70 3600.78 3602.36 Overall average: 3592.18 feet Program: assign06c.m REMOVE UNNECESSARY STATEMENTS FROM PREVIOUS PROGRAMS. INCLUDE APPROPRIATE COMMENTS Use exist to determine if the file is available. Only print message if file is not New commands textread save selected columns of a file available. Use textread() to save the first and last years into a two column matrix. Continue to use printfO Print water level with 2 decimal places Print year, month with 0 decimal places Align numbers under headings Do not save the other years. Do not use a loop. Print the lake_powell matrix with title and year column headings Do not use a loop to print matrix. Use mean to determine and print the average elevation of the water for each uonth for the four-year period. Create a 2-column table of the results print the table. See example 7.2, p.254 as given in previously 05 and 06 Lake Powell Water Levels (in feet) Problem Constants: (with unit comments) Use constant names Output: 2013 3594.38 3601.41 3589.11 3598.63 3584.49 3597.85 3583.02 3599.75 3584.70 3604-68 3587.01 3610.94 3583.07 3609.47 2016 assign06 (1)-pdf arch NUM MONTHS 12; FIRST YEAR 2013; LAST YEAR 2016; % INPUT months 1:NUM MONTHS yearsFIRST YEAR: LAST YEAR: s read data file lake_powel1-load 'lake_powell.txt S OR load lake _powell.txt s print with title and year column headings. fprintf Lake Powe11 Water Levela (in feet) In fprintf'8d'years) fprintf ('a) % print contents of lake_powoll for month 1:NUM MONTHS fprintr ('9.25, lake poell(month, fprintf"n') end PART B fprintfnPART B: Determine average elevation of water level for each year and overall aver yearAve -mean (lake powe11): fprintf('Average for Each Year (in feot)la' fprintf '8d, years) fprintf( n') fprintf ( % 9 . 2 f.. yea rAve) fprintf n overallave mean (yearAve) : fprintf (' Overall average: .2ffeetin', overal Ave) PART C fprinte( InPART C: Determine how many months of each for year-l:length (years) overall averagen) over_average (year-length ( find ( lake_powol ( :-Year) >overal Ave ) ) , end fprintf During 5.0f the lake vas above average for 3.0f months Ln. yearsjover average]) %PART D Eprintt nPART D: monthly average-mean (lake_powe11' Determine and print average elevation of the rater for each monhI print Average elevation (in feet) of the vater for each monthn ) assign06 (2)pdf assign06 (1).pd

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions