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!