Vectorized indexing cell array
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I have several (5000+) pressure-time histories in a cell array Data. Each cell in the Data array holds a two column vector of time and pressure. However, the times may be different, and the length of the vector may be different. I currently do this:
(read in all the data files in to the Data cell array)
Times = [];
for index = 1 : numel(file_list)
Times = [Times ; Data{index}(:,1)];
end
Times = unique(Times);
% Interpolate on to consistent time base
Press_all = zeros(length(Times), numel(file_list));
for index = 1 : numel(file_list)
Press_all(:,index) = interp1(Data{index}(:,1), Data{index}(:,2), Times);
end
Is there a better way, or a way to vectorize this? I would like to eliminate the for loops and do something like:
Times = unique(Data{1 : numel(file_list)}(:,1));
Except that the first : does not work.
And then maybe even:
Press_all = interp1(Data{1 : numel(file_list)}(:,1), Data{1 : numel(file_list)}(:,2), Times);
, although that may be pushing things a bit too far.
Thanks for any input
0 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Matrices and Arrays in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!