How do I apply a sample time to an array of values that represent data points at different times?
I have a table/array/matrix of values in the MATLAB workspace, representing data from sensors, each arranged in a column. The columns have different sample times, depending on the sensor, and I want to separate these columns so that I can have workspace variables that correspond to each sample rate. I also want to add that sampling rate so that the data points correspond to a specific time of measurement. How do I do this?
matlab , signal , signal processing , array ,
ANSWER:
Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.
This is achievable in MATLAB with some commands to clean up our data first and then create a Timeseries Object. Assuming you have an array of real numbers of size 300x6 meaning you have 6 sensors and 300 data points for each for example:
>> data = [rand(100,2) ; zeros(200,2)]
>> data = [data, rand(300,4)];
first you can select the columns with a specific sample rate, for example the first 2:
>> dataAtSampleRate1 = data(:,1:2);
then we can clean it up by noticing that many of the values of these columns are zero, meaning it was padded with non-existent data, so we can remove them. First we find the first row where the padding starts:
>> [index, ~] = find(~dataAtSampleRate1,1)
then we remove the data starting at that row:
>> dataAtSampleRate1(index:end,:) = [];
Now we need to create a Timeseries Object to specify a sample time for the data and assign times to each row:
>> ts = timeseries(dataAtSampleRate1)
Now we can double-click on the “ts” variable in the Workspace window, select “Uniform time vector” and add start and end times for the data collection. This will automatically calculate the measurement time for all the data points in “ts”.