Calculate percentage of zeros and ones in my vector?

前端 未结 2 1307
被撕碎了的回忆
被撕碎了的回忆 2021-01-25 02:32

I\'ve already have my vector and number of zeros and ones with this code:

u=[1 1 1 1 1 0 0 0 1 1 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0]
transitions=(find(u~=[u(2:end),          


        
2条回答
  •  野性不改
    2021-01-25 03:28

    This is just psuedocode so it'll need to be translated, but here's a potential solution:

    total = 0;
    total_ones = 0;
    total_zeroes = 0;
    
    for(i=0; i

提交回复
热议问题