[心得] 新手問一個函式的問題已回收
我正要做一個氣溫的EMD(經驗模態分解)
從中央大學下載了一個eemd.m
以前從沒碰過matlab,正在看書自學
有個可能在各位眼中很蠢的問題想請教大家
現有一筆1*96的氣溫資料temp01.txt
內容是某測站連續96筆的月均溫
以下是函式eemd.m
% This is an EMD/EEMD program
%
% function allmode=eemd(Y,Nstd,NE)
%
% INPUT:
% Y: Inputted data;
% Nstd: ratio of the standard deviation of the added noise and that of
Y;
% NE: Ensemble number for the EEMD
% OUTPUT:
% A matrix of N*(m+1) matrix, where N is the length of the input
% data Y, and m=fix(log2(N))-1. Column 1 is the original data, columns
2, 3, ...
% m are the IMFs from high to low frequency, and comlumn (m+1) is the
% residual (over all trend).
%
% NOTE:
% It should be noted that when Nstd is set to zero and NE is set to 1,
the
% program degenerates to a EMD program.
%
% References can be found in the "Reference" section.
%
% The code is prepared by Zhaohua Wu. For questions, please read the "Q&A"
section or
% contact
% zwu@fsu.edu
%
function allmode=eemd(Y,Nstd,NE)
xsize=length(Y);
dd=1:1:xsize;
Ystd=std(Y);
Y=Y/Ystd;
TNM=fix(log2(xsize))-1;
TNM2=TNM+2;
for kk=1:1:TNM2,
for ii=1:1:xsize,
allmode(ii,kk)=0.0;
end
end
for iii=1:1:NE,
for i=1:xsize,
temp=randn(1,1)*Nstd;
X1(i)=Y(i)+temp;
end
for jj=1:1:xsize,
mode(jj,1) = Y(jj);
end
xorigin = X1;
xend = xorigin;
nmode = 1;
while nmode <= TNM,
xstart = xend;
iter = 1;
while iter<=10,
[spmax, spmin, flag]=extrema(xstart);
upper= spline(spmax(:,1),spmax(:,2),dd);
lower= spline(spmin(:,1),spmin(:,2),dd);
mean_ul = (upper + lower)/2;
xstart = xstart - mean_ul;
iter = iter +1;
end
xend = xend - xstart;
nmode=nmode+1;
for jj=1:1:xsize,
mode(jj,nmode) = xstart(jj);
end
end
for jj=1:1:xsize,
mode(jj,nmode+1)=xend(jj);
end
allmode=allmode+mode;
end
allmode=allmode/NE;
allmode=allmode*Ystd;
在這個涵式中
要輸入的引數為Y,Nstd,NE
Y為氣溫資料,在note中設定Nstd為0,NE為1
我的輸入如下
>> load temp01.txt
>> Y=temp01(:,1)
>> Nstd=0
Nstd =
0
>> NE=1
NE =
1
接著試著執行都是錯誤
>> eemd
??? Input argument "Y" is undefined.
Error in ==> eemd at 27
xsize=length(Y);
>> eemd(Y,Nstd,NE)
??? Undefined function or method 'extrema' for input arguments of type
'double'.
Error in ==> eemd at 59
[spmax, spmin, flag]=extrema(xstart);
>> eemd(temp01(:,1),0,1)
??? Undefined function or method 'extrema' for input arguments of type
'double'.
Error in ==> eemd at 59
[spmax, spmin, flag]=extrema(xstart);
有高手可以提點我一下那裏有錯嗎?
從書中實在找不到解決方法
感恩
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.167.194.15
→
08/15 18:13, , 1F
08/15 18:13, 1F
推
08/16 08:22, , 2F
08/16 08:22, 2F
→
08/18 09:44, , 3F
08/18 09:44, 3F
MATLAB 近期熱門文章
PTT數位生活區 即時熱門文章