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

A file named temp.txt contains temperature information collected from a set of t

ID: 3559806 • Letter: A

Question

A file named temp.txt contains temperature information collected from a set of
thermocouples. The data in the file are shown in the table below. The first column
consists of time measurements (one for each hour of the day), and the remaining columns correspond to temperature measurements at different sensors in an industrial plant.
(a) Write a Matlab program that prints the index numbers (rows and columns) of
temperature data values greater than 85.0.
(b) Find the index numbers (rows and columns) of temperature data values less than
65.0.
(c) Find the maximum and minimum temperatures in the file and the corresponding
hour and sensor number.
(d) What percentage of the temperature readings at each sensor lies between 65.0 and
85.0?

Everything must be in Matlab!

Explanation / Answer

Matlab Code

fmt = repmat('%f',1,4);
fid = fopen('temp.txt', 'r');
data = textscan(fid, fmt, 'HeaderLines', 1, 'CollectOutput', 1);
fclose(fid);
a = data{1};
s=size(a);

% Find temperature greater than 85
fprintf('Index numbers of temperature values greater than 85.0 ');
for i=1:s(1)
for j=2:s(2)
if a(i,j)> 85.0
fprintf('Row= %d ; Column=%d ; Temp=%0.2f ', i,j,a(i,j));
else
end
end
end

% Find temp less than 65
fprintf('Index numbers of temperature values less than 65.0 ');
for i=1:s(1)
for j=2:s(2)
if a(i,j)< 65.0
fprintf('Row= %d ; Column=%d ; Temp=%0.2f ', i,j,a(i,j));
else
end
end
end

% Maximum temperature
a_t=a(:,2:4);
mx=max(max(a_t),[],2);
for i=1:s(1)
for j=1:s(2)-1
if a_t(i,j)== mx
fprintf('Maximum temp= %0.2f, Hour=%d, Sensor=%d ',mx,a(i,1),j);
else
end
end
end

% Minimum temperature
mn=min(min(a_t),[],2);
for i=1:s(1)
for j=1:s(2)-1
if a_t(i,j)== mn
fprintf('Minimum temp= %0.2f, Hour=%d, Sensor=%d ',mn,a(i,1),j);
else
end
end
end

% Percentage temperature
count=zeros(1,3);
for i=1:s(1)
for j=1:s(2)-1
if a_t(i,j)>= 65.00 && a_t(i,j)<85.00
count(1,j)=count(1,j)+1;
else
end
end
end
for i=1:3
fprintf('At sensor= %d , Percent of tem between 65 and 85 is= %0.2f ',i, count(1,i)./s(1)*100);
end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote