Create a time table
4 visualizaciones (últimos 30 días)
Miguel Albuquerque el 21 de Jun. de 2022
Hey guys, thanks in advance.
I have a program that reads samples from a hardware receiver. When it starts receiving I use:
fprintf('Start of LimeSDR\n');
Then it receives this samples:
indRx1 = 1; % index of the last received sample
[samples1, ~, samplesLength1] = dev.receive(Fs*Ts,1);
bufferRx1(indRx1:indRx1+samplesLength1-1) = samples1;
and stops receiving:
% Cleanup and shutdown by stopping the RX stream and having MATLAB delete the handle object.
fprintf('Stop of LimeSDR\n');
I want to create a timetable that has start time, stop time, Fs(frequency sampling), and samples1(number of samples).
I have done this
But this only gives me a column with start time and the samples. How can I do this,
Ishaan Mehta el 25 de Jun. de 2022
Editada: Ishaan Mehta el 25 de Jun. de 2022
From your last comment, as per my understanding, you want to record start_time and end_time in the same column, and then samples1 and fs in other columns in a timetable.
A timetable is a MATLAB datatype which associates a timestamp with each of the rows stored in it.
Please have a look at MATLAB timetable datatype documentation.
According to me, you can go for the table datatype for a single column storing both the start_time and end_time.
For using timetable datatype, the start_time and end_time must be in different columns.
Incase you want to store the time-duration between start_time and stop_time in the first column, that can be done by subtracting start_time from the end_time as demonstrated in the code below.
You can use the following code as a reference.
table1 = table; % table with start_time and end_time in same column
table2 = table; % table with time-duration in first column
table3 = table; % table with start_time and end_time in separate columns
for i = 1:3
fs = 10; % dummy fs
samples1 = 100; % dummy samples1
start_time = datetime('now');
stop_time = datetime('now') + seconds(i*2); % dummy stop_time
% Variables above are initialised to dummy values for demonstration.
% You should get all the variables above from your own program only,
% before the following code is executed
nRows = height(table2);
table1 = [table1; table(string(start_time) + " : " + string(stop_time), samples1, fs)];
table2 = [table2; table(stop_time - start_time, samples1, fs)];
table3 = [table3; table(start_time, stop_time, samples1, fs)];
% rename table columns
table1.Properties.VariableNames = ["time" "samples" "frequency"];
table2.Properties.VariableNames = ["time duration" "samples" "frequency"];
Hope it helps,