I would like to decompose the waveform by using the following procedure to decompose the wav file into IMF by EMD(Empirical mode decomposition) using EEMD(ensemble EMD) code, but it does not work.
I use the following code to load the wav file into MATLAB and get EMD.
[X,fs] = audioread('sample.wav');
sound(X,fs);
t = (0:length(X)-1)/fs;
plot(t,X)
xlabel('Time(s)')
[imf,residual,info] = emd(X,'Interpolation','pchip');
hht(imf,fs)
Can you please tell me why it does not work?

 采纳的回答

Star Strider
Star Strider 2021-9-14

0 个投票

I am not absolutely certain what the problem is, because ‘does not work’ can mean just about anything.
Note that according to the documentation, the first argument ‘x’, the time-domain signal must be ‘specified as a real-valued vector, or a single-variable timetable with a single column. If x is a timetable, x must contain increasing, finite row times.
MATLAB sound files characteristically contain 2 columns, corresponding to the left and right channels of a stereopohonic recording. If that is the situation with your ‘X’, choose one column or the other, not both, to present to the emd function.
.

8 个评论

Dear Star Strider
Thank you for your answer.
I apologize for the lack of explanation.
The wav file is a mono sound, so it contains only one waveform.
I would like to run EEMD with the following code referring to the discussion in the following URL.
load ('sample.mat');
y=val;
fs=500;
t=0:length(y)/fs;
[modes] = eemd(y, goal, ens, nos);
I want to proceed EEMD to decompose the waveform of a wav file instead of a mat file, but I can't adapt the wav file to this code.
The code for enforcing EMD, the prototype of EEMD, is shown below, and in this case I am able to decompose the wav file.
[X,fs] = audioread('sample.wav');
sound(X,fs);
t = (0:length(X)-1)/fs;
plot(t,X)
xlabel('Time(s)')
emd(X,'Interpolation','pchip','Display',1)
I would like to do the same thing with EEMD, which is an improved version of EMD, but I am having difficulty with the process from reading the wav file to adapting it to the EEMD code.
My pleasure.
You will have to write your own EEMD code, since the only related MATLAB function is the emd function you quoted. There is no MATLAB code for EEMD, at least that I could find on an Interweb search.
I will delete my Answer in a few hours.
Thank you.
I think the EEMD code attached is the recommended one, but does that mean that this code cannot be used?
I have no idea. The function does not appear to have any internal documentation, so I have no idea what the arguments are, how to use the function, or how to interpret the results..
The code in the file is:
function [modes] = eemd(y, goal, ens, nos)
stdy = std(y);
if stdy < 0.01
stdy = 1;
end
y = y ./ stdy;
sz = length(y);
modes = zeros(goal+1, sz);
%%
parfor k = 1:ens
disp(['Running ensemble #' num2str(k)]);
wn = randn(1, sz) .* nos;
y1 = y + wn;
y2 = y - wn;
modes = modes + emd(y1, goal);
if nos > 0 && ens > 1
modes = modes + emd(y2, goal);
end
end
%%
modes = modes .* stdy ./ (ens);
if nos > 0 && ens > 1
modes = modes ./ 2;
end
end
.
I apologize for being very inexperienced with MATLAB code.
The attached code is the most recent version of EEMD's code for MATLAB made by Xianliang Zhang.
According to the paper, this code is used for waveform decomposition, but is there any description of the arguments in this code?
Is it possible to run it by downloading the new function file described here?
No worries! We all have to start somewhere.
The only argument appears to be the file name, however ‘rwl2tsm.m’, ‘rwlinp.m’, ‘sov2tsm3.m’, and ‘trailnan.m’ apparently also need to be downloaded to your MATLAB user path, before calling this function. (I suggest creating a new directory for all these functions, and then adding it to your MATLAB user path. (See What Is the MATLAB Search Path? if you are not familiar with MATLAB.)
It also requires a ‘.rwl’ file format that I do not recognise. It will probably be necessary for you to find out those details from the website.
‘Is it possible to run it by downloading the new function file described here?
Possibly, however I cannot determine that. It has a number of other requirements — including the specific file format that may need to be created with other functions available from the same website — so it will be necessary to check into all those before running it.
Posting the code in the file —
% This is a program used to develop chronologies based on EEMD
% USEAGE EXAMPLE: y=EemdCrn('E:\trunk\aa\tmp.rwl');
% The code is prepared by Xianliang Zhang. For questions, please contact
% zhangxianliang@syau.edu.cn
% function crn=EemdCrn(file)
% INPUT:
% file: raw measurement file in tucson format '.rwl',The full path of
% the file is needed
% FILE NOTE:
% The function files rwl2tsm.m,rwlinp.m,sov2tsm3.m,and trailnan.m,should
% be downloaded from the website http://www.ltrr.arizona.edu/~dmeko/toolbox.html
% OUTPUT:
% crn.txt:the chronology in txt format
% crn:the chronology in mat format
% NOTE:
% eemd program should be added to current path or the path of MABLAB toolbox (C:\Program Files\MATLAB\R2012a)
% eemd program could be downloaded from the website http://rcada.ncu.edu.tw/
% reference: Wu and Huang, 2009, Ensemble empirical mode decomposition:
% a noise-assisted data analysis method. Advances in adaptive data
% analysis. 1(1): 1-41
function crn=EemdCrn(file)
[X,yrX]=rwl2tsm(file); %read the file
year=yrX;
tmpz=X;
tmpz(isnan(tmpz))=0;
ss=size(tmpz,1);
for i=1:ss
tp1=tmpz(i,:);
ll(i,:)=length(find(tp1>0));
end
tmp=(sum(tmpz,2))./ll; % calculate the mean of all the series
tmpemd=eemd(tmp,0.2,200);
crn=[year,tmpemd(:,1)./tmpemd(:,end)];
fname=['crn.txt'];
fid = fopen(fname,'wt');
fprintf(fid,'%d %6.4f \r ', crn');
fclose(fid);
end
.
Dear Star Strider
Thank you for your kind attention.
I will follow your advice and try.
I am sure that some unclear points will come up in the future and I will ask you again.
Thank you very much!
As always, my pleasure!
.

请先登录,再进行评论。

更多回答(0 个)

产品

版本

R2021a

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by