Index exceeds matrix dimensions

Asked by Yussif Moro Awelisah

Yussif Moro Awelisah (view profile)

on 17 Sep 2019 at 3:05
Latest activity Commented on by Yussif Moro Awelisah

Yussif Moro Awelisah (view profile)

on 23 Sep 2019 at 2:05
Index exceeds matrix dimensions.
Error in tvf_emd (line 47)
y = [fliplr(y(2:2+num_padding-1)) y fliplr(y(end-num_padding:end-1))]; % padding to deal with boundary effect (symmetric).
trying to solve this problem in my code but im finding it difficult. Please can anyone help solve this problem for me. its urgent as I need to complete my paper.
attached are the codes and data used.

Walter Roberson

Walter Roberson (view profile)

on 17 Sep 2019 at 4:28

Tags

Answer by Walter Roberson

Walter Roberson (view profile)

on 17 Sep 2019 at 4:39

length is defined as:
temp = size(TheInput)
if any(temp == 0)
length is 0 no matter what the other dimensions are
else
length is max(temp)
end
length is not any particular dimension: for a matrix that is not empty, length is the largest dimension.
You then use effectively go row by row through temp_x, with the rows being length 231, which is less than num_padding, so using num_padding exceeds the end of the row.

Yussif Moro Awelisah

Yussif Moro Awelisah (view profile)

on 18 Sep 2019 at 3:24
the previous version raises this error :
Index exceeds matrix dimensions.
Error in tvf_emd (line 55)
y = [flipud(y(2:2+num_padding-1)) y flipud(y(end-num_padding:end-1))]; % padding to deal with boundary effect (symmetric)
whiles the current version raises this error:
Error using horzcat
Dimensions of matrices being concatenated are not consistent.
Error in tvf_emd (line 48)
y = [fliplr(y(2:2+num_padding-1)) y fliplr(y(end-num_padding:end-1))]; % padding to deal with boundary effect (symmetric).
both still records an error.
Walter Roberson

Walter Roberson (view profile)

on 18 Sep 2019 at 3:39
Using length() is always wrong for this purpose.
Walter Roberson

Walter Roberson (view profile)

on 18 Sep 2019 at 3:44
I am not clear as to why you removed the for y loop ?
The code does not have enough documentation for me to understand what you want to do.
Did you remove the for y loop in an attempt to vectorize the calculations?
tt=1:numel(y);
That code is wrong for 2D arrays y.
It looks to me as if the best way to proceed would be to use a for loop whose indices were the row numbers of temp_x, and inside the loop,
y = temp_x(row_number, :);
After which you do the padding and so on.

Answer by Yussif Moro Awelisah

Yussif Moro Awelisah (view profile)

on 18 Sep 2019 at 4:21

Once again I am more than grateful. I only removed the for loop because originally the for loop wasnt there. I added the for loop to convert y into a row vector which stil didnt work. I have replaced it and tried it with the 'size' instead of length but same error still occurs.
I think I have taken alot of your time so I hope on your leisure time you can try to run the data on the code to feel how best this can be solved. The code run on tvf_emd(x) as the input variable . so x is the data I have attached. Also both the tvf_emd and splinfit work together.
Thanks alot .

Walter Roberson

Walter Roberson (view profile)

on 18 Sep 2019 at 4:59
It looks to me as if the best way to proceed would be to use a for loop whose indices were the row numbers of temp_x, and inside the loop,
y = temp_x(row_number, :);
After which you do the padding and so on.
As in
for row_number = 1 : size(temp_x,1)
y = temp_x(row_number, :);
y = [fliplr(y(2:2+num_padding-1)) y fliplr(y(end-num_padding:end-1))]; % padding to deal with boundary effect (symmetric)
....
end
Yussif Moro Awelisah

Yussif Moro Awelisah (view profile)

on 20 Sep 2019 at 9:18
I am grateful. I have all means but I finally decided to use the strnum to convert the data to numeric. this courses a problem I hope you wil have idea about:
Index of element to remove exceeds matrix dimensions.
Error in tvf_emd (line 131)
imf(nimf:MAX_IMF,:)=[]
again the data and code is attached.
Yussif Moro Awelisah

Yussif Moro Awelisah (view profile)

on 23 Sep 2019 at 2:05
y = temp_x;
y = temp_x(row_number, :);
flag_stopiter=0;
for iter=1:100
for row_number = 1 : size(temp_x,1)
y = temp_x(row_number, :);
y = [fliplr(y(2:2+num_padding-1)) y fliplr(y(end-num_padding:end-1))]; % padding to deal with boundary effect (symmetric)
end
Undefined function or variable "row_number".
Error in tvf_emd (line 44)
y = temp_x(row_number, :);
Please in this case how should the roe_number be defined?