我有一个带的1x3细胞
timepositionrawdata = {time, lat, lon};
% Extract every fourth instance of the raw data
time = timepositionrawdata{1,1}(1:4:end);
lat = timepositionrawdata{1,2}(1:4:end);
lon = timepositionrawdata{1,3}(1:4:end);
timepositionrawdata = {time, lat, lon};
% Delete and add appropriate rows to match image sequence times
timepositionrawdata{1}(278,:) = [];
timepositionrawdata{2}(278,:) = [];
timepositionrawdata{3}(278,:) = [];
timepositionrawdata = timepositionrawdata{1}([1:281, 281:end],:);
timepositionrawdata = timepositionrawdata{2}([1:281, 281:end],:);
timepositionrawdata = timepositionrawdata{3}([1:281, 281:end],:);
我希望能够删除整个单元格中的特定行。你是如何利用cellfun来做到这一点的?
首先需要编写一个正确处理一个单元格的函数,然后使用cellfun
将其应用于单元格数组。
function time = process_one_cell(time)
time = time(1:4:end);
time(278, :) = [];
time = time([1:281, 281:end], :); % I'm not sure why you're doing this, looks kind of pointless.
end
然后调用函数如下
timepositionrawdata = cellfun(@process_one_cell, timepositionrawdata, 'UniformOutput', 0);
% or if you prefer to be more verbose
timepositionrawdata = cellfun(@(x) process_one_cell(x), timepositionrawdata, 'UniformOutput', 0);