#### saruji

Joined Oct 18, 2011
14
so slightly stuck on a problem:I am given a data set, whos first column is time from 0-19 seconds with 1 second intervals, the columns 2:6 have various sensor measurements. I am asked to extract the min measurement and the max measurements for each sensor and then use MatLab to determine at what time they occurred... stuck on finding out at what time they occurred, any help would be greatly appreciated, thanks

attached the sensor.dat file

my code so far:

http://pastebin.com/xRZHNikn

or for quick reference of my code so far
%Read the data file and print the number of sensors and the number of
%seconds of data contained in the file. Before that load the sensor.dat
%file
[seconds, sensors] = size(sensor)

%Problem 4.4b
%Found both the maximum value and the minimum value recorded on each
%sensor, and showed at what time they occured.
max1 = max(sensor, 2))
max2 = max(sensor, 3))
max3 = max(sensor, 4))
max4 = max(sensor, 5))
max5 = max(sensor, 6))

min1 = min(sensor, 2))
min2 = min(sensor, 3))
min3 = min(sensor, 4))
min4 = min(sensor, 5))
min5 = min(sensor, 6))

time = sensor, 1)
sensor = sensor, 2:6)

???? not sure on how to proceed

#### Attachments

• 651 bytes Views: 19

#### panic mode

Joined Oct 10, 2011
2,793
max1=sensor(1,1);
max1time=1;
for i=2:N
if sensor(i,1)>max1
max1=sensor(i,1);
max1time=i;
end;
end;

#### saruji

Joined Oct 18, 2011
14
thank you, I solved it a different way.

max1 = sortrows(sensor, -2);
max1_value = max(sensor, 2))
time_at_max1 = max1(1, 1)

I sort a sensor column in descending order and then print out the readings from the top columns for the needed column.