Example1
The first signal is a composition of three simple components, namely a general linear trend and two dif- ferent harmonics:
The signal, its three constituent modes, and the composite Fourier spectrum are shown in Fig. 9. The main challenge of this signal is the linear growth term, whose higher order harmonics spread over the whole spectrum.
The recovered VMD modes constitute a nice partition of the input spectrum, with each mode being clearly dominant around its respective center frequency. The three modes in time domain show nice separation into three distinct signals of characteristic oscillations. Compared to the EMD results, the proposed VMD method performs clearly better, with less spurious oscillations in the trend and mid-frequency signal.
julia> using VMD,Random,Plots
julia> T = 1000;
julia> t = (1:T)/T;
julia> sample_frequency = 1000;
julia> # modes
v_1 = @. 6t;
julia> v_2 = @. cos(8π*t)
1000-element Array{Float64,1}:
0.9996841892832999
0.9987369566060175
0.9971589002606139
0.9949510169813002
0.9921147013144779
0.9886517447379141
0.9845643345292053
0.9798550523842469
0.9745268727865771
0.9685831611286311
⋮
0.9798550523842463
0.9845643345292052
0.9886517447379136
0.9921147013144778
0.9949510169813
0.9971589002606139
0.9987369566060175
0.9996841892833
1.0
julia> v_3 = @. 0.5cos(40π*t)
1000-element Array{Float64,1}:
0.49605735065723894
0.48429158056431554
0.46488824294412573
0.4381533400219318
0.4045084971874737
0.3644843137107058
0.3187119948743449
0.2679133974894983
0.2128896457825364
0.15450849718747373
⋮
0.26791339748949866
0.31871199487434215
0.36448431371070555
0.4045084971874712
0.4381533400219313
0.4648882429441239
0.48429158056431515
0.4960573506572382
0.5
julia> # composite signal, including noise
f = v_1 + v_2 + v_3 + 0.1*randn(length(v_1));
julia> # some sample parameters for VMD
alpha = 2000; # moderate bandwidth constraint
julia> tau = 0; # noise-tolerance (no strict fidelity enforcement)
julia> K = 3; # 3 modes
julia> DC = false; # no DC part imposed
julia> init = 0; # initialize omegas uniformly
julia> tol = 1e-7;
julia> v = vmd(f ; alpha = alpha,tau = tau,K = K,DC = false,init = init,tol = tol,sample_frequency = sample_frequency)
--iteration times 324 -- error 9.73134810942782e-8
julia> p0 = VMD.plot(v,k=0)
Plot{Plots.GRBackend() n=2}
julia> savefig(p0,"1_0.png")
/home/runner/.julia/packages/GR/BwGt2/src/../deps/gr/bin/gksqt: error while loading shared libraries: libQt5Widgets.so.5: cannot open shared object file: No such file or directory
connect: Connection refused
GKS: can't connect to GKS socket application
GKS: Open failed in routine OPEN_WS
GKS: GKS not in proper state. GKS must be either in the state WSOP or WSAC in routine ACTIVATE_WS
julia> p1 = VMD.plot(v,k=1)
Plot{Plots.GRBackend() n=2}
julia> savefig(p1,"1_1.png")
/home/runner/.julia/packages/GR/BwGt2/src/../deps/gr/bin/gksqt: error while loading shared libraries: libQt5Widgets.so.5: cannot open shared object file: No such file or directory
connect: Connection refused
GKS: can't connect to GKS socket application
GKS: Open failed in routine OPEN_WS
GKS: GKS not in proper state. GKS must be either in the state WSOP or WSAC in routine ACTIVATE_WS
julia> p2 = VMD.plot(v,k=2)
Plot{Plots.GRBackend() n=2}
julia> savefig(p2,"1_2.png")
/home/runner/.julia/packages/GR/BwGt2/src/../deps/gr/bin/gksqt: error while loading shared libraries: libQt5Widgets.so.5: cannot open shared object file: No such file or directory
connect: Connection refused
GKS: can't connect to GKS socket application
GKS: Open failed in routine OPEN_WS
GKS: GKS not in proper state. GKS must be either in the state WSOP or WSAC in routine ACTIVATE_WS
julia> p3 = VMD.plot(v,k=3)
Plot{Plots.GRBackend() n=2}
julia> savefig(p3,"1_3.png")
/home/runner/.julia/packages/GR/BwGt2/src/../deps/gr/bin/gksqt: error while loading shared libraries: libQt5Widgets.so.5: cannot open shared object file: No such file or directory
connect: Connection refused
GKS: can't connect to GKS socket application
GKS: Open failed in routine OPEN_WS
GKS: GKS not in proper state. GKS must be either in the state WSOP or WSAC in routine ACTIVATE_WS