Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need Help in MATLAB. How to solve my last two error. Thanks. You are writting a program that will calculate the monthly maximum and
I need Help in MATLAB. How to solve my last two error. Thanks.
You are writting a program that will calculate the monthly maximum and minimum temperatures for a selected year. The program already has let the year be selected and the selected year is currently stored as a scalar in the variable Year. You need to read in the sheet from the Excel file which corresponds to the selected year and store the numeric data in TempData. Read in the entire sheet and do not give any cell ranges From this data calculate the maximum monthly temperatures (the maximum of the MAX rows) and the minimum monthly temperatures (the minimum of the MIN rows) for each month. These values should be stored as MonthMax and MonthMin and should be 12x1 vectors (one monthly minimum and maximum value for every month of the selected year) Hints: .To not hardcode the sheet name, you need to create a string which matches the sheet name using the value in the variable Year. What function do - Finding the min and max monthly temperatures can be done in one line each. You don't need to do it 12 times (once for each month). Take a look at -When you find the maximum monthly temperature, you want to find the maximum of the MAX rows, not the MIN rows, therefore you want to pull out you know that lets you created a formatted string that can include variable values? the doc pages for the min and max functions to see how to do this. Additionally, look at the next hint for help indexing everyother row (the opposite is true for the minimum monthly temperature). You can do this with indexing! In addition to indexing a range, like 3:11 which would pull positions 3 through 11, you can include an increment value in the middle, like 3:2:11 which would pull the positions 3 through 11 in increments of 2 (in other words positions 3, 5, 7, 9, 11) 1 %% Variables to be used 2 % Inputs 3 % Clemson-Temp .xIsx is a spreadsheet as described in the problem statement 4 % Year-scalar which contains the yea r for which the stats are to be calculated 6 % Intermediate 7 % TempData-matrix containing all the numeric data from the Excel sheet | 9 % Outputs 10 % MonthMax-12x1 vector of the monthly maximums 11 % MonthMn-12x1 vector of the monthly minimums 12 13 %% Inputs -Only edit this section if you are testing this code in MATLAB 14 Generate-Year % Comment this out to test in MATLAB. This generates the variable Year. 15 % You also have to read in the Excel sheet. You will need to create your own copy of the Excel file to use when 16 17 %% PROGRAM 18 % start writing your program here 19 % Generate the sheet name based on the variable Year (see problem description for hint) 20 21 % read in Excel file 22 TempData xlsread( 'Clemson_Temp.xlsx, 'Y2008') 23 % calculate the monthly maximums (this can be done in one or two lines-see problem description for hints) 24 MonthMax-max (TempData) 25 % calculate the monthly minimums (this can be done in one or two nes- see problem description for hints) 26 MonthMin-min(TempData) Monthly Max Check Variable MonthMax must be of size 12 1]. It is currently of size [1 33]. Check where the variable is assigned a value. Your MonthMax values are incorrect. 3 Monthly Min Check Variable MonthMin must be of size [12 1]. It is currently of size [1 33]. Check where the variable is assigned a value Your MonthMin values are incorrect
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