Detecting Remainder Starts and Ends when Gaps are Present

1 回表示 (過去 30 日間)
Midimistro
Midimistro 2018 年 11 月 15 日
Say I have an array known as divideRem that is a result of using rem(A,B) where A is a vector that is always counting up but contains gaps in certain places that have no set gap size such that:
A= [2821,2822,2823,2824,2825,2827,2830,2831,2832,2836,2839,2841,2842,2843,2844,2845,2861,2862,2863,2864,2865,2866,2867,2881,2885,2888,2891,2892,2893,2894,2901,2921,2922,2923,2924,2925];
B=10;
divideRem=rem(A,B)
%thus:
% divideRem=[1,2,3,4,5,7,0,1,2,6,9,1,2,3,4,5,1,2,3,4,5,6,7,1,5,8,1,2,3,4,1,1,2,3,4,5];
What is the most effective way to detect/find where the start (aka divideRem==1 or smallest value that is not 0) and end of the repeating series (highest value or divideRem==0) that occurs in divideRem such that the resulting truth vectors are found to be:
divRemStart=[1,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,1,1,0,0,0,0];
divRemEnd=[0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,1,1,0,0,0,0,1];
Notes:
  • 1 may not always be the start (as seen above),
  • 0 might not always be the end (as seen above),
  • and that if (A(i)-A(i+1)>10), the divideRem(i) and divideRem(i+1) will not be part of the same start/end set;
The end goal is to create start/end sets of equal sizes.
Any ideas?

回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by