- Identifying discontinous numbers in the matrix A.
- Exeute the for loop with +5 and - 5 from each discontinuous number.
for loop sequence from the matrix
3 views (last 30 days)
I intend to execute the for loop, in which sequence for given index needs to be called from a matrix. For e.g. I have a matrix named 'A', it got the discontinous numbers, like 10 to 19, then 120 to 150 and 238 to 247 so on.. now I ned to exeute the for loop with +5 and - 5 from the point where discontinuity exists, e.g. as shown in below code
I have attached the matrix A here. Please help with this...
for i = [5:1:15 115:1:125 233:1:243]
% my code
Sai Veeramachaneni on 27 Jan 2021
Your question can be split into two parts.
discontinous = [A(1)]%Stores the vector of discontinous numbers
for i = 2:numel(A)
discontinous = [discontinous A(i)];
for i = 1:numel(discontinous)
for j = discontinous(i)-5:discontinous(i)+5
%Required tasks here.