Please find below required MATLAB code along with necessary details in comments:
--------------------------------------------- assign07.m
clear all; clc;
NUM_MONTHS = 12;
FIRST_YEAR = 2013;
LAST_YEAR = 2016;
WATER_LEVELS = 'lake_powell.txt';
%*****INPUT*****
% open file
[ fileID, msg ] = fopen( WATER_LEVELS, 'r' );
% file available ?
if fileID < 0
fprintf( '%s \n', msg )
else
% file available continue
years = FIRST_YEAR:LAST_YEAR;
% read lake_powell.txt
for month = 1:NUM_MONTHS
for year = 1:length(years)
lake_powell(month,year) = fscanf(fileID, '%f', 1);
end
end
% **** OUTPUT ****
% determine average elevation of water level for each year and
overall average\n')
printWaterLevel(lake_powell, years, NUM_MONTHS);
end % good file open
NUM_MONTHS = 12;
FIRST_YEAR = 2013;
LAST_YEAR = 2016;
WATER_LEVELS = 'lake_powell.txt';
months=1:1:NUM_MONTHS;
%*****INPUT*****
% file avaialable ?
if ~exist( WATER_LEVELS, 'file' )
fprintf( 'File not found\n' )
else
% read data file
[ lake_powell(:,1),lake_powell(:,2) ] = textread( WATER_LEVELS,
'%f%*f%*f%f' );
% **** OUTPUT ****
printWaterLevelSummary(lake_powell, months, NUM_MONTHS);
end % file found
----------------------------------------------------------------- printMonthAve.m
function []=printMonthAve(lake_powell,months)
monthly_average=mean(lake_powell');
table = [months;monthly_average];
fprintf('\n Average elevation (in feet) of the water for each
month\n')
fprintf(' Month Elevation\n')
fprintf(' %2d %9.2f\n',table)
end
---------------------------------------------------------- printWaterLevel.m
function []=printWaterLevel(lake_powell, years, NUM_MONTHS)
% determine average elevation of water level for each year and
overall average\n')
yearAve = printYearAve(lake_powell, years);
fprintf(' Average for Each Year (in feet)\n')
fprintf('%8d ', years)
fprintf('\n')
fprintf('%9.2f', yearAve)
fprintf('\n')
overallAve = mean(yearAve);
fprintf(' Overall average: %.2f feet\n', overallAve);
fprintf('Months for which water level is above
average:\n');
printAboveAve(lake_powell, years,yearAve);
end
----------------------------------------------------------- printWaterLevelSummary.m
function []=printWaterLevelSummary(lake_powell, months, NUM_MONTHS)
% Determine and print average elevation of the water for each
month\n')
printMonthAve(lake_powell,months)
end
------------------------------------------------------------- printAboveAve.m
function []=printAboveAve(lake_powell, years,overallAve)
for k=1:length(years)
aboveAve = find(lake_powell(k,:)>overallAve(k));
countAve(k)=length(aboveAve);
end
fprintf('%8d ', years)
fprintf('\n')
fprintf('%8d ', countAve)
fprintf('\n')
SAMPLE OUTPUT
Matlab help *****CONSTANT***** NUM_MONTHS = 12; FIRST_YEAR = 2013; LAST_YEAR = 2016; %*****...
can anyone help me figure out how fo write matlab code for these problems? BME 2013 Spring 2019 Exam 3 Matlab Review Sheet 1. Given the vector of patient body temperatures T (98.6, 102, 101, 99,98.9, 102.1, 100.3, 101.2, 98.4 97.6, 100] use conditional statements and loops to write a program that determines and displays (using the fprintf function) the number of patients with a fever and patients without a fever. The program must ask the user to input the...
USE MATLAB TO WRITE A CODE FOR THIS 2. Writ example 4.5% as 4.5) and the number of monthly payments (use the Calculate the down payment using the percent down payment e e a program that gets a cost, percent down payment, annual interest rate as a percent (for ntered, the loan amount (cost - own payment) and monthly interest rate as a decimal number -not a percent. Call your payment function to calculate the payment on the loan amount....
MATLAB : Practice-4 (Oct. 31/ Nov. 1) Seat No. Name: Solve the following problems and write in the answers in blue and the plot in the box. Save the file in a pdf format and submit the answer script file and the pdf file to E-Class. 1. Re-do the Sample Problem 6-11 (Flight of a model rocket), but with the following conditions. - 16N force during the first 0.2 second - Parachute open when the downward velocity reaches 25 m/s...
Create a single script (.m file) to complete this assignment. Unless directed otherwise, use meaningful variable names for each variable: do not use the default variable ans to store your results. For this assignment do not suppress your output with semi- colons (). Each problem (ie. Problem 1. Problem 2, and Problem 4) should be in a separate cell, using the cell mode feature of MATLAB; the subparts should all be contained in the same cell as the parent problem....
Use the program MATLAB to answer the following question:Use the program MATLAB to answer the following question: KE Mona File Use The Program MATLA x 0 Info Assignment 8, Matlab, spring 2017.docx O Download Close box 2/2 5. Write a program that accepts a year and determines whether the year is a leap year. Use the mod function. The output should be the variable extra day, which should be 1 if the year is a leap year and 0 otherwise....
MATLAB question: I have written a code to solve for a metals resitance. Here is the problem statement: Part 1 (Algorithms) – due Friday: Think about how you might solve the problem of calculating the resistance of a given group of metals depending on the type of metal, the length of the wire and the area of the wire (if given the diameter only – so you must calculate the area). Write instructions (an algorithm) for a script that behaves...
The first two parts should be solved by Matlab. This is from an intro to Numerical Analysis Class and I have provided the Alog 3.2 in below. Please write the whole codes for me. Alog3.2 % NEWTONS INTERPOLATORY DIVIDED-DIFFERENCE FORMULA ALGORITHM 3.2 % To obtain the divided-difference coefficients of the % interpolatory polynomial P on the (n+1) distinct numbers x(0), % x(1), ..., x(n) for the function f: % INPUT: numbers x(0), x(1), ..., x(n); values f(x(0)), f(x(1)), % ...,...
(a) (4 points) Fill in the blanks in the following MATLAB function M file trap so that it implements the composilu trapezidul rulo, using a soquence of w -1,2, 4, 8, 16,... trapezoids, to approximatel d . This M file uses the MATLAB built-in function trapz. If 401) and y=() f(!)..... fr. 1)). 3= ($1, then the execution of z = trapz(x, y) approximates using the composite trapezoidal rule (with trapezoids). (Note that the entries of are labeled starting at...
Urgent: Help with MatLab Program Create a Matlab function called seasonif. m which assigns to the numerical value of a month within the year a numerical value for the particular season in which that month occurs (see Table 2 above for numerical values to assign seasons). As usual, January is mouth 1, February is mouth 2, mid so on. Your function should allow decimal values (e.g. 4.68 should be considered part of April), but any value less than 1 or...
i need help in this assignment by using matlab. codes only or capture the solutionPlot t versus v with line width 1.5, dotted, red colored line, triangle shaped, marker with size 10, black edge, and green face. A1-2. a. Determine the drae coefficient (cd) using the equation: cd = g*m/upsilon^2from the exploratory data analysis below: g=9.81 b. Find out average, maximum, and minimum of cd by the command meant(cd), max(cd), and min(cd) respectively. c. Determine the predicted terminal velocity by...