1 view (last 30 days)

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
on 17 Sep 2019

num_padding = round(length(temp_x)*0.5);% padding number

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.

Walter Roberson
on 18 Sep 2019

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);

ind_remov_pad=num_padding+1:numel(y)-num_paddi

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.

Yussif M. Awelisah
on 18 Sep 2019

Walter Roberson
on 18 Sep 2019

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

Opportunities for recent engineering grads.

Apply Today
## 1 Comment

## Direct link to this comment

https://de.mathworks.com/matlabcentral/answers/480710-index-exceeds-matrix-dimensions#comment_746671

⋮## Direct link to this comment

https://de.mathworks.com/matlabcentral/answers/480710-index-exceeds-matrix-dimensions#comment_746671

Sign in to comment.