matlab中的数据滤波
我是matlab的初学者。我正在做一个小项目,我面临着过滤方面的问题 下面是我的数据子集matlab中的数据滤波,matlab,filtering,Matlab,Filtering,我是matlab的初学者。我正在做一个小项目,我面临着过滤方面的问题 下面是我的数据子集 'black' 11 '6/21/2013' <1x1 cell> 'blue' 11 '6/3/2013' <1x1 cell> 'yellow'12 '4/18/2015' <1x1 cell> 'white' 13 '11/11/2013'<1x1 cell> 'red' 14 '8/4/2014' <1x1 cell>
'black' 11 '6/21/2013' <1x1 cell>
'blue' 11 '6/3/2013' <1x1 cell>
'yellow'12 '4/18/2015' <1x1 cell>
'white' 13 '11/11/2013'<1x1 cell>
'red' 14 '8/4/2014' <1x1 cell>
'blue' 15 '8/4/2014' <1x1 cell>
'yellow'16 '12/6/2014' <1x1 cell>
'red' 17 '10/4/2014' <1x1 cell>
'red' 18 '4/17/2015' <1x2 cell>
green' 19 '12/14/2014'<1x1 cell>
orange' 20 '3/18/2015' <1x1 cell>
谢谢你的帮助
StartDate = input('What is the start date ','s'); % Prompt user for start date
EndDate = input('What is the end date ','s'); % Prompt user for end date
StartDate = datenum(StartDate); % Convert to datenum
EndDate = datenum(EndDate);
a=0;b=0;c=0; % Initalise counters
alphabet = {'a', 'b', 'c', ....} %EXPAND THIS TO Z
lettercount = zeros(1,numel(alphabet));
for ii = 1:size(YourCell,1)
celldat = datenum(YourCell{ii,3}); % Get date
if celldat > StartDate && celldat < EndDate % Check time boundaries
for jj = 1:size(YourCell{ii,4})
tmp = strcmp(YourCell{ii,4}{jj},alphabet);
lettercount = lettercount + tmp;
end
end
end
这里发生的事情是,首先提示用户输入时间间隔的开始和结束日期。然后将所有日期转换为datenum以便于比较。计数器初始化,然后根据提示的日期检查每个单元格的日期,如果在时间段内,字母收集在lettercount中,其中lettercount1=a,lettercount2=b,等等@Adrian感谢您的输入,问题是我有从a到z的字母,我刚刚在这里显示了3个a,b,例如,如果你的单元格每次只包含一个字母,我可以这样做。在您的示例中,有一个单元格包含2个字母;不,这就是问题所在,我在单元格中有多个字母。我在内部单元格周围添加了一个循环,逐个检查每个元素。哦,我明白了!问题是字母。如果我有数字而不是字母,我可以改变,然后adjust@Adriaan-谢谢你的输入,问题是我有从a到z的字母,我刚刚在这里展示了3个a,b,c例如,谢谢你的输入,问题是我有从a到z的字母,我刚刚在这里展示了3个例子,a,b,c
from date:
to date:
count
f1
b1
c1
StartDate = input('What is the start date ','s'); % Prompt user for start date
EndDate = input('What is the end date ','s'); % Prompt user for end date
StartDate = datenum(StartDate); % Convert to datenum
EndDate = datenum(EndDate);
a=0;b=0;c=0; % Initalise counters
alphabet = {'a', 'b', 'c', ....} %EXPAND THIS TO Z
lettercount = zeros(1,numel(alphabet));
for ii = 1:size(YourCell,1)
celldat = datenum(YourCell{ii,3}); % Get date
if celldat > StartDate && celldat < EndDate % Check time boundaries
for jj = 1:size(YourCell{ii,4})
tmp = strcmp(YourCell{ii,4}{jj},alphabet);
lettercount = lettercount + tmp;
end
end
end