Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I know how to import excel datas to MATLAB. [num,txt,raw] = xlsread(\'filename\'

ID: 3748931 • Letter: I

Question

I know how to import excel datas to MATLAB.

[num,txt,raw] = xlsread('filename')

But I am totally stuck in computing the number of nice, cold and hot days. I know that I should assign number between the given temperature intervals to a variable. But I cannot figure out how to do that. I would really appreciate if someone could explain briefly. If I could only assign the the temperature between the 3 given intervals into 3 main identifiers(hot,cold,nice) I could solve the problem too. I just cannot understand how I can use the math equation 70<x<80 where x= niceDays on MATLAB. What matlab syntax should I use for that? I have been trying to find on youtube and from the MATLAB help for at least 9 hours.

The Excel data File link: https://expirebox.com/download/6fc80b5bc02e6c5984055cef26752e7f.html

If it helps, I found this very similar problem on internet "https://www.kau.edu.sa/Files/0053697/Subjects/chapter8-appendix1.pdf" however, it is explained for c programming. not for MATLAB.

The accompanying Excel File ('New_Brunswick_Temp_Data.xlsx') contains the average daily temperature data for New Brunswick from 1981 to 2010. Suppose that the days with average temperature between 70 degrees to 80 are considered nice days, the days with average temperature less than 70 degrees are cold and the days with average temperature more than 80 degrees are considered hot days. Hint: Pay attention to the directives that are given at the top of the Excel sheet. a) Write a MATLAB code to read the data from the Excel file and compute the number of nice, cold and hot days. b) Compute the average temperature in a cold, nice and hot day.

Explanation / Answer

%comment if u have any doubt ;-)

% if u find the answer is useful,give like ;-)

[num,txt,raw] = xlsread('filename');

num(1,:) = []; % Remove 1st row,since it contains day of month

num(:,32) = []; % remove last column,since it cotains all the average temperature of that month

% now,num contains only temperatures(both valid and invalid = NA)

nice = num((70 < num) & (num < 80));

nice_sum = sum(nice);

cold = num((num<70));

cold_sum = sum(cold);

hot = num((num>80));

hot_sum = sum(hot);

avg_tmp = (nice_sum + cold_sum + hot_sum)/3;

Total_days = numel(num);

valid = (num(num>=0));

invalid = Total_days - numel(valid);

disp("Total days : ")

disp(Total_days);

disp("Total InValid days : ")

disp(invalid);

disp("Total Valid days : ")

disp(numel(valid));

disp("Total Nice days : ")

disp(numel(nice));

disp("Total cold days : ")

disp(numel(cold));

disp("Total hot days : ")

disp(numel(hot));

disp("Average temperature : ")

disp(avg_tmp);