6 views (last 30 days)

Show older comments

please I will be grateful for any help for this error:

Error using -

Matrix dimensions must agree.

Error in tvf_emd (line 136)

temp_x = temp_x-y(ind_remov_pad);

the code is below:

if flag_stopiter

imf(nimf,:)=y(ind_remov_pad);

temp_x = temp_x-y(ind_remov_pad);

break;

end

per isakson
on 19 Oct 2019

Edited: per isakson
on 23 Oct 2019

I get a different error. One reason for the difference in the wording is that we run different releases of Matlab(?). I run R2018b. However, more important it seems we are running different versions of your program. (Note: The line number might differ, since I have deleted some blank lines.)

>> dbstop if error

>> imf = tvf_emd( DS_DATA_ODU )

Unable to perform assignment because the size of the left side is 1-by-500 and the size of the right side is 231-by-500.

Error in tvf_emd (line 39)

imf(nimf,:)=temp_x;

39 imf(nimf,:)=temp_x;

K>> whos imf nimf temp_x

Name Size Bytes Class Attributes

imf 50x500 200000 double

nimf 1x1 8 double

temp_x 231x500 924000 double

K>> nimf

nimf =

18

This error is because you cannot overwrite one row of imf by the full matrix temp_x. The error of your question is most likely of the same kind.

The line imf(nimf,:)=temp_x; should probably be imf(nimf,:)=temp_x( some_index, : ) ;

In response to comment

If it ain't broke, don't fix it

"The original version [of tvf_emd] can be found at file exchange" Yes, I found Time varying filter based empirical mode decomposition(TVF-EMD). In the example, signal_decomposition.m, the function, tvf_emd, takes a row vector (signal) and returns a matrix. The number of rows of the output matrix depends on the input signal. There is no indication that the functions could take a matrix, i.e. many signals, as input. The documentation of tvf_emd isn't enough to make major modifications of the code - IMO.

Your goal is to make a function that takes a matrix. And returns what? Simplest first, make a wrapper. Try

>> imf_array = my_tvf_emd( DS_DATA_ODU );

>> whos imf_array DS_DATA_ODU

Name Size Bytes Class Attributes

DS_DATA_ODU 231x500 924000 double

imf_array 231x1 11129872 cell

where

function imf_array = my_tvf_emd( signals )

len = size( signals, 1 );

imf_array = cell( len, 1 );

for jj = 1 : len

imf_array{jj} = tvf_emd( signals(jj,:) );

end

end

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

Start Hunting!