Vectorized indexing cell array
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!