hey i have this assignment to do im not asking you guys to do it just simply explain to me the steps to complete the third number, i cant seem to find a way to make it work, thanks for any help

2 views (last 30 days)
  1. Suppose the MAT file is stored in a “Data” subfolder. Load the data from the MAT file once you check the file does exist. Then, generate one graph with two subplots in a 2x1 layout. The upper subplot shows the annual average water levels across the 12 months of each year versus the years 2000 to 2007 as the x-axis. The lower subplot shows the monthly average water levels across the 8 years versus the months January to December as the x-axis. You can use 1 to 12 to represent the months. Your plot should be properly labeled and titled.
  2. Request a user input on a year that the user is interested in. Make sure your program only accepts a valid input for year 2000 to year 2007. If the user input is invalid, display a message “Please enter a year between 2000 and 2007” and exit the program. We call the year before this particular year “last year” if there are data for that year, and call the year after it “next year” if there are data for that year. The 2 or 3 years adjacent to the interested year is called a “checking group”.
  3. Compare the annual average water levels of the years in a “checking group”.- If the average water levels keep increasing, show a message “Average water levels are rising”.- If the average water levels keep decreasing, show a message “Average water levels are decreasing.”- If the interested year input by the user has the lowest average water level among this checking group, show a message “Year yyyy has the lowest water level among recent 3 years.” Replace “yyyy” with the particular year input by the user.- If the interested year input by the user has the highest average water level among this checking group, show a message “Year yyyy has the highest water level among recent 3 years.” Replace “yyyy” with the particular year input by the user.
here is what i have for a code so far
%%Checking if file exist on record and loading values
a = exist('H:\downloads\lake_powell.mat','file');
if a == 2
load('H:\downloads\lake_powell.mat');
else disp('File is not found');
end
%%Preperations for both graphs
y1 = mean(water_levels);
x1 = [2000:1:2007];
y2 = mean(water_levels,2);
x2 = [1:1:12];
%%Plotting graphs
figure;
subplot(2,1,1);
plot(x1,y1,'b');
title('Annual average water levels');
xlabel('Year');
ylabel('Average level of water');
subplot(2,1,2);
plot(x2,y2,'r');
title('Monthly average water levels');
xlabel('Month');
ylabel('Average level of water');
%%Requesting user input and determining if its a valid option
user = input('What year would you like to examine? ');
if user > 2007 || user < 2000;
disp('Please enter a year between 2000 and 2007');
elseif user == 2000;
disp('No availible data on previous year');
next_year = user+1;
checking_group = [user; next_year;];
elseif user == 2007;
disp('No availible data on next year');
last_year = user-1;
checking_group = [last_year; user;];
elseif user <= 2006 && user >= 2001;
last_year = user-1;
next_year = user+1;
checking_group = [last_year; user; next_year;];
end

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!