%% Clear the command line, clear all workspace variable clc, clear %% Import sam
ID: 3142832 • Letter: #
Question
%% Clear the command line, clear all workspace variable
clc, clear
%% Import sample weather data
wd = xlsread('weather_data.xls'); % read in the data to wd using xlsread
wd = wd'; % transpose wd, so that months are in columns
month = 2 % set the month of January
%% Average in a month
month_values = wd(:,month)
month_values(month_values<0)=[]
average_in_a_month = mean(month_values)
%% Max in a month
max_in_a_month = max(wd(:,month))
%% days of month when zero inches fell
days_when_zero = find(month_values==0)
%% # of days zero inches fell
% num_days_when_zero = numel(days_when_zero)
num_days_when_zero = sum(month_values==0)
%% days when some rain fell
num_days_when_zero = numel(days_when_zero)
Need help to write script?
%% average inches of only days in which some rain fell
Need help to write script?
Explanation / Answer
days when some rain fell
num_days_when_not_zero = length(month_values) - sum(month_values==0)
average inches of only days in which some rain fell
average_when_rain_not_zero= sum(month_values)/num_days_when_not_zero
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.