Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

There are parts a, b, and c to this question in MATlab. this is lake_powell.txt: This is Assign 05 in MatLab: clc, clear all %*****CONSTANT*****

image text in transcribed

image text in transcribed

There are parts a, b, and c to this question in MATlab.

this is lake_powell.txt:

image text in transcribedThis is Assign 05 in MatLab:

clc, clear all %*****CONSTANT*****

%*****INPUT***** load('lake_powell.txt');

years = (2013:1:2016); fprintf(' Lake Powell Water Levels (in feet) ');

%print title and year column headings.

for i=1:length(years) fprintf('%5d\t',years(i)); end

%print contents of lake_powell

for i=1:size(lake_powell,1) fprintf(' '); for j=1:size(lake_powell,2) fprintf('%7.2f\t',lake_powell(i,j)); end end

fprintf(' '); fprintf(' ');

%print and determine the average elevation of water level for each year and overall average fprintf('PART B: Determine average elevation of water level for each year and overall average'); mean_each_year = mean(lake_powell,1); fprintf(' Average for Each Year (in feet) ');

for i=1:length(years) fprintf(' %d\t',years(i)); end fprintf(' '); for i=1:length(mean_each_year) fprintf('%4.2f\t',mean_each_year(i)); end overall_mean = mean(mean_each_year); fprintf(' Overall average : %.2f feet',overall_mean); disp (' ') disp (' ') %print and determine how many months of each year > overall average fprintf('PART C: Determine how many months of each year > overall average'); number_of_months = zeros(1,size(lake_powell,2)); for i=1:size(lake_powell,2) number_of_months(i) = length(find(lake_powell(:,i)>overall_mean)); end for i=1:length(years) fprintf(' During %d the lake was above average for %d months',years(i),number_of_months(i)); end fprintf(' '); fprintf(' '); %print and determine and print average elevation of the water for each month fprintf('PART D: Determine and print average elevation of the water for each month'); mean_each_month = mean(lake_powell,2); fprintf(' Average elevation (in feet) of water for each month Month\t Elevation'); for i=1:length(mean_each_month) fprintf(' %d\t %.2f',i,mean_each_month(i)); end fprintf(' '); %plot the water level values in lake_powell with labels on the x- and y-axis date = 2013:1/12:2017-1/12; plot(date,lake_powell(:)); title('Water Level Values in Lake Powell'); xlabel('Year') ylabel('Water level, ft')

Program: assign06a.m Revise your assign05.m by adding the exist) function to print a message only if the data file is not available. The output should be the same as with assign05.m. New commands exist () COMP 1200m-Spring 2019-assign06-p. 1 of 2 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 () fscanf () nested for loops Only print message if file is not available Use nested for loops to read one water level value at a time into the lake powell matrix lakepowell (month,year) fscanf (fileID, '%f', 1); Use mean to determine the average elevation of the water level for each year and the Continue to use fprintf ) Print water level with 2 decimal places Print year, month with 0 decimal places Align numbers under headings Use constant names - 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 Additional Problem Constants: (with unit comments) data file name Average for Each Year i feet) 2013 2014 2015 2016 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 Use textread) to save the first and last years into a two column matrix. Print the lake_powell matrix with title and year column headings Use mean to determine and print the average elevation of the water for each month for available Do not save the other years. Do not use a loop Do not use a loop to print matrix the four-year period. Create a 2-column table of the results; print the table. See Continue to use fprintf ) Print water level with 2 decimal places Print year, month with 0 decimal places Align numbers under headings example 7.2, p.254 Problem Constants: (with unit comments) as given in previously 05 and 06 Use constant names Output: Lake Powell Water Levels (in feet) 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 3575.85 3605.56 3571.07 3602.27 3570.70 3601.27 3569.69 3599.71 3565.73 3596.79 2016 Average elevation (in feet) of the water for each month Month Elevation 3597.89 3593.87 3591.17 3591.39 3594.69 3598.98 3596.27 3590.70 3586.67 3585.98 3584.70 3581.26 10 12 3.5943800e+003 3.5634100e+003 3.5962600e+003 3.6014100e+003 3.5891100e+003 3.5603500e+003 3.5919400e+003 3.5986300e+003 3.5844900e+003 3.5574200e+003 3.5892200e+003 3.5978500e+003 3.5830200e+003 3.5575200e+003 3.5899400e+003 3.5997500e+003 3.5847000e+003 3.5716000e+003 3.5982700e+003 3.6046800e+003 3.5870100e+003 3.5980600e+003 3.60 93600e+003 3.6109400e+003 3.5830700e+003 3.6077300e+003 3.6087900e+003 3.6094700e+003 3.5758500e+003 3.604 9600e+003 3.6049300e+003 3.6055600e+003 3.5710700e+003 3.6022000e+003 3.6020800e+003 3.6022700e+003 3.5707000e+003 3.6023100e+003 3.6061200e+003 3.6012700e+003 3.5696900e+003 3.6026500e+003 3.6074600e+003 3.5997100e+003 3.5657300e+003 3.6001400e+003 3.6049600e+003 3.5967900e+003 Program: assign06a.m Revise your assign05.m by adding the exist) function to print a message only if the data file is not available. The output should be the same as with assign05.m. New commands exist () COMP 1200m-Spring 2019-assign06-p. 1 of 2 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 () fscanf () nested for loops Only print message if file is not available Use nested for loops to read one water level value at a time into the lake powell matrix lakepowell (month,year) fscanf (fileID, '%f', 1); Use mean to determine the average elevation of the water level for each year and the Continue to use fprintf ) Print water level with 2 decimal places Print year, month with 0 decimal places Align numbers under headings Use constant names - 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 Additional Problem Constants: (with unit comments) data file name Average for Each Year i feet) 2013 2014 2015 2016 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 Use textread) to save the first and last years into a two column matrix. Print the lake_powell matrix with title and year column headings Use mean to determine and print the average elevation of the water for each month for available Do not save the other years. Do not use a loop Do not use a loop to print matrix the four-year period. Create a 2-column table of the results; print the table. See Continue to use fprintf ) Print water level with 2 decimal places Print year, month with 0 decimal places Align numbers under headings example 7.2, p.254 Problem Constants: (with unit comments) as given in previously 05 and 06 Use constant names Output: Lake Powell Water Levels (in feet) 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 3575.85 3605.56 3571.07 3602.27 3570.70 3601.27 3569.69 3599.71 3565.73 3596.79 2016 Average elevation (in feet) of the water for each month Month Elevation 3597.89 3593.87 3591.17 3591.39 3594.69 3598.98 3596.27 3590.70 3586.67 3585.98 3584.70 3581.26 10 12 3.5943800e+003 3.5634100e+003 3.5962600e+003 3.6014100e+003 3.5891100e+003 3.5603500e+003 3.5919400e+003 3.5986300e+003 3.5844900e+003 3.5574200e+003 3.5892200e+003 3.5978500e+003 3.5830200e+003 3.5575200e+003 3.5899400e+003 3.5997500e+003 3.5847000e+003 3.5716000e+003 3.5982700e+003 3.6046800e+003 3.5870100e+003 3.5980600e+003 3.60 93600e+003 3.6109400e+003 3.5830700e+003 3.6077300e+003 3.6087900e+003 3.6094700e+003 3.5758500e+003 3.604 9600e+003 3.6049300e+003 3.6055600e+003 3.5710700e+003 3.6022000e+003 3.6020800e+003 3.6022700e+003 3.5707000e+003 3.6023100e+003 3.6061200e+003 3.6012700e+003 3.5696900e+003 3.6026500e+003 3.6074600e+003 3.5997100e+003 3.5657300e+003 3.6001400e+003 3.6049600e+003 3.5967900e+003

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions