Rebuild time series to same size time series
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
I have some data organized on a 1x16 cell. Each cell has a #x36 double. Where # can vary from cell to cell. Column 34 of each double has the time vector. I would like to cut the 16 doubles for a specific time (stored in column 34, for example at 10800), so that my 1x16 cell has now for each cell a 10800x36 double.
Thanks
0 comentarios
Respuestas (1)
BhaTTa
el 29 de Ag. de 2024
Hey @Isma_gp , To achieve this, you can iterate over each cell in your 1x16 cell array, extract the time vector from column 34, and then select the rows corresponding to your desired time range (e.g., up to 10800 seconds). Here's how you can do this in MATLAB:
% Initialize dataCell with example data
dataCell = cell(1, 16); % Create a 1x16 cell array
% Populate each cell with a #x36 matrix (example data)
for i = 1:16
numRows = randi([10000, 12000]); % Example: random number of rows
dataCell{i} = [rand(numRows, 33), linspace(0, 12000, numRows)', rand(numRows, 2)]; % Example data with time in column 34
end
% Define the target time up to which you want to cut the data
targetTime = 10800;
% Initialize a new cell array to store the cut data
cutDataCell = cell(1, 16);
% Process each matrix in dataCell
for i = 1:length(dataCell)
% Extract the current matrix from the cell
currentMatrix = dataCell{i};
% Ensure the matrix has at least 36 columns
if size(currentMatrix, 2) < 36
error('Matrix in cell %d does not have 36 columns.', i);
end
% Extract the time vector from column 34
timeVector = currentMatrix(:, 34);
% Find the indices of rows where the time is less than or equal to the target time
indices = find(timeVector <= targetTime);
% Select the rows up to the target time
cutMatrix = currentMatrix(indices, :);
% Store the cut matrix in the new cell array
cutDataCell{i} = cutMatrix;
end
% Display a message indicating completion
disp('Data matrices have been cut to the specified time.');
0 comentarios
Ver también
Categorías
Más información sobre Fourier Analysis and Filtering en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!