Asked by Lev Mihailov
on 6 Aug 2019 at 13:18

Hello! I have a 1x15 matrix, the code is presented

[xdata,x]=min(Data); % Data 45x350 x=[ 16 16 16 31 16 0 16....]

a=[15 15 15 15 15....] % 1x350

for i = 1:length(x)-1

if x(i)+a(i)>a(i)

ax=Data((x(i)-a(i):x(i)),i) ;

ay=Data((x(i):x(i)+a(i),i) ;

A{i}=ax;

B{i}=ay;

else x(i)+a(i)<a(i) ;

ax=0 ;

ay=0 ;

A{i}=ax;

B{i}=ay;

end

end

%%% x(i)+a(i) 31+15=46

It so happened that in one value x (i) + a (i) exceeds the size of the matrix, can anyone tell me the condition how can I get around this?

Opportunities for recent engineering grads.

Apply Today
## 4 Comments

## Adam (view profile)

## Direct link to this comment

https://es.mathworks.com/matlabcentral/answers/475075-matrix-non-exceeding-condition#comment_732399

## Guillaume (view profile)

## Direct link to this comment

https://es.mathworks.com/matlabcentral/answers/475075-matrix-non-exceeding-condition#comment_732402

## Lev Mihailov (view profile)

## Direct link to this comment

https://es.mathworks.com/matlabcentral/answers/475075-matrix-non-exceeding-condition#comment_732404

## Guillaume (view profile)

## Direct link to this comment

https://es.mathworks.com/matlabcentral/answers/475075-matrix-non-exceeding-condition#comment_732424

Sign in to comment.