create a matrix that keeps only the sequential numbers
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
Akira Agata
2023-8-3
What happens if the 1st column consists of two sequential numbers, like: [1 2 3 4 7 8 9 10]' ?
采纳的回答
Stephen23
2023-8-3
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!