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

Create a MATLAB *.m script file that will solve the following 2 problems. Use MA

ID: 3822538 • Letter: C

Question

Create a MATLAB *.m script file that will solve the following 2 problems. Use MATLAB array operations to solve the problems. Problem: A scientist has an incubator to hatch some rare birds. Because the percentage of hatchlings is smaller than expected, the scientist has decided to monitor the temperature inside the incubator every hour for one day. The data has been store in arrays that may be found in Labs8to10.mat. Download this file to the folder you use for MATLAB. The ideal temperature for the incubator is 100 to 105 degrees. You are going to help the scientist analyze the data. Use the load command to open the file (two arrays should appear in the Workspace Window). Use the find command to determine the indices of the temperatures less than 100. Use the find command to determine the indices of the temperatures greater than 105. Determine the temperatures that are too low using the indices for low temperatures and the temperature array. Determine the times the temperature was too low using the indices for low temperatures and the time array. Determine the temperatures that arc high using the indices for high temperatures and the temperature array. Determine the times the temperature was too high using the indices for high temperatures and the time array. Use the fprintf function to output a message similar to The incubator had a low temperature of ____ at _:00. for each of the low temperatures (the blanks should contain actual values). Use the fprintf function to output a message similar to The incubator had a high temperature of ____ at _:00. for each of the high temperatures (the blanks should contain actual values). You should be able to solve the problem using less than 15 MATLAB commands.

Explanation / Answer

%make sure you have Labs8to10.mat

load('Labs8to10.mat')

lo_indices=find(temperature<100);
hi_indices = find(temperature>105);

lo_temp=temperature(lo_indices);
hi_temp=temperature(hi_indices);

lo_times=time(lo_indices);
hi_times=time(hi_indices);

for i =1:size(lo_temp,2)
fprintf('incubator had a low temperature of %d at %d:00. ',lo_temp(i),lo_times(i))
end

for i =1:size(hi_temp,2)
fprintf('incubator had a high temperature of %d at %d:00. ',hi_temp(i),hi_times(i))
end