create a matrix that keeps only the sequential numbers
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Alberto Acri
le 3 Août 2023
Réponse apportée : Stephen23
le 3 Août 2023
Hi! I need to create a matrix that keeps only the sequential numbers in the first column (and keep the corresponding number in the second column) and delete everything else. Here is an example:

3 commentaires
Akira Agata
le 3 Août 2023
What happens if the 1st column consists of two sequential numbers, like: [1 2 3 4 7 8 9 10]' ?
Réponse acceptée
Stephen23
le 3 Août 2023
S = load('CountArray_A_zoom_select.mat');
A = S.CountArray_A_zoom_select
X = diff(A(:,1))==1;
Y = [X;0]|[0;X];
B = A(Y,:)
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!