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

MATLAB Write a script to read an Excel file. The file contains 2 sheets with dat

ID: 3701913 • Letter: M

Question

MATLAB

Write a script to read an Excel file. The file contains 2 sheets with data. The spreadsheet contains time and corresponding temperature for Day 1 and Day 2.
We want to plot the data for either day 1 or day 2, according to user’s choice.
If user chooses to display day 1, he/she must enter 1.
If user chooses to display day 2, he/she must enter 2.
Any other entry should display an error message and ask user to try again.

TIME 0 3 6 9 12 15 18 21
TEMPERATURE 55.5 52.4 52.6 55.7 75.6 77.7 70.3 66.6

Explanation / Answer

%I am assuming the excel files has 2 sheets, with the first sheet having data for day 1
%and sheet 2 having data for day2
k=1;
while k==1
k=0;
day=input('Enter day(1/2): ');
if day~=1 && day~=2
k=1;
disp('Invalid input. Try again')
end
end
data=xlsread('TempData.xlsx',day);%change name of file accoedingly
time=data(:,1);
temp=data(:,2);
plot(time,temp)
xlabel('time')
ylabel('temperature')
%if there is any problem, please tell in comments