Suppose that a file named sensordat contains information col

Suppose that a file named sensor.dat contains information collected from a set of sensors. Your instructor may provide you with this file, or you may need to enter it by hand from the following data: Each row contains a set of sensor readings, with the first row containing values collected at 0 seconds, the second row containing values collected at 1.0 seconds, and so on. Read the data file and print the number of sensors and the number of seconds of data contained in the file. Find both the maximum value and the minimum value recorded on each sensor. Use MATLAB to determine at what times they occurred. Find the mean and standard deviation for each sensor and for all the data values collected. Remember, column 1 does not contain sensor data; it contains time data.

Solution

Function to get number of sensors and seconds of data recorded:

function [seconds, sensorCount] = countSize(a)
    [row, col] = size(a);
    seconds = row;
    sensorCount = col - 1;
end

Function to get max and mean reading of each sensor:

function [maxSensor, MinSensor] = countSize(a)
    maxAll = max(a); %gives max of each column
    minAll = min(a); %gives min of each column
    maxSensor = maxAll(1, 2:end); %remove data of first column
    minSensor = minAll(1, 2:end);
end

Function to get SD of each sensor data:

function [sdSensor] = countSize(a)
    sdAll = std(a); %gives the sd of each column
    sdSensor = sdAll(1, 2:end);
end

since u are allowed to enter data through keyboad, use that, since reading data is file dependent. Without the file structure we cannot provide you a funtion to read the data.

 Suppose that a file named sensor.dat contains information collected from a set of sensors. Your instructor may provide you with this file, or you may need to e

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site