Error using - Matrix dimensions must agree.

조회 수: 1 (최근 30일)
Yussif M. Awelisah
Yussif M. Awelisah 2019년 10월 19일
댓글: Yussif M. Awelisah 2019년 10월 23일
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
  댓글 수: 5
Yussif M. Awelisah
Yussif M. Awelisah 2019년 10월 19일
Please I did not. I have attached that.
per isakson
per isakson 2019년 10월 19일
We wrote our comments at the same time, which explains the confusion.

댓글을 달려면 로그인하십시오.

채택된 답변

per isakson
per isakson 2019년 10월 19일
편집: per isakson 2019년 10월 23일
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
  댓글 수: 10
per isakson
per isakson 2019년 10월 23일
편집: per isakson 2019년 10월 23일
I tried to convince you not to modify tvf_emd. It's difficult and you will probably never get it right. Thus use tvf_emd as it comes from the FEX.
As an alternative I proposed a Wrapper function, which I called my_tvf_emd. Your comment (2+ hour ago) doesn't show that you tried my_tvf_emd. On the contrary you copied and modified pieces of my code.
The line (the first line of your script)
imf_array = tvf_emd( DS_DATA_ODU )
will certainly cause an error. We know that by now. The function, tvf_emd, expects a vector. Respect that.
Do exactly the following steps
  1. Create the wrapper, my_tvf_emd. Copy the code below the word "where" to an empty editor "document" and save it to a file named my_tvf_emd.m
  2. Make sure that tvf_emd invokes the file from the fex-submission. Not one of your modified versions. Run which tvf_emd -all The fex version shall appear at the top of the result.
  3. In the command window run (I used >> to indicate command window.)
imf_array = my_tvf_emd( DS_DATA_ODU );
whos imf_array DS_DATA_ODU
Yussif M. Awelisah
Yussif M. Awelisah 2019년 10월 23일
this worked and I am sincerely grateful.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Timing and presenting 2D and 3D stimuli에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by