liliang 发表于 2007-5-5 03:17

这个条件判断是多余的吗?

while SD > 0.3
% 找极值点

d = diff(h);
% approximate derivative

maxmin = [];


for i=1:N-2

if d(i)==0
% we are on a zero

maxmin = ;

elseif sign(d(i))~=sign(d(i+1))


% we are straddling a zero so

maxmin = ;
% define zero as at i+1 (not i)

end

end



if size(maxmin,2) < 2
% 极值点数目小于2个跳出循环

break
%(maxmin,2)中的2代表列数即极值点数

end



% divide maxmin into maxes and mins

if maxmin(1)>maxmin(2)
% first one is a max not a min

maxes = maxmin(1:2:length(maxmin));

mins
= maxmin(2:2:length(maxmin));

else

% is the other way around

maxes = maxmin(2:2:length(maxmin));

mins
= maxmin(1:2:length(maxmin));

end



% 极值点的位置信息

maxes = ;

mins
= [1 mins
N];


这个程序,其中请主要关注这两个地方
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:N-2

if d(i)==0
% we are on a zero

maxmin = ;

elseif sign(d(i))~=sign(d(i+1))


% we are straddling a zero so

maxmin = ;
% define zero as at i+1 (not i)

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if maxmin(1)>maxmin(2)
% first one is a max not a min

maxes = maxmin(1:2:length(maxmin));

mins
= maxmin(2:2:length(maxmin));

else

% is the other way around

maxes = maxmin(2:2:length(maxmin));

mins
= maxmin(1:2:length(maxmin));

end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
请问这个判断maxmin(1)>maxmin(2) 是不是多余的?

[ 本帖最后由 eight 于 2007-5-5 11:21 编辑 ]

liliang 发表于 2007-5-5 12:16

这个判断maxmin(1)>maxmin(2)条件是不是恒为真?下面的程序每次都执行
maxes = maxmin(1:2:length(maxmin));
mins
= maxmin(2:2:length(maxmin));
这两句,但对求包络结果没有影响,因此可以简化只有这两句
maxes = maxmin(1:2:length(maxmin));
mins
= maxmin(2:2:length(maxmin));
不知我这样分析对不对?

liliang 发表于 2007-5-5 14:49

怎么没有人看一下呢?
页: [1]
查看完整版本: 这个条件判断是多余的吗?