向量非零区域块
前言
求解一个向量中,连续非零区域的数目。
% /************************************************************************ % * Copyright(c) 2017 ZRJ % * All rights reserved. % * % * File: none_zero_block_num.m % * Brief: 向量非零区域块数目 % * Version: 1.0 % * Author: ZRJ % * Email: happyamyhope@163.com % * Date: 2017/02/28 % * Reference: % * History: % * 20160919:向量非零区域块数目; % % ************************************************************************/ function block_num = none_zero_block_num( a ) % 向量非零区域块数目 % Nonzero regional block number %程序功能:Apply function to Get the Number of none zero block in one vector. %输入: % cdata -- input vector data. %输出: % block_num -- output of Nonzero regional block number. num = 0;%非零区域块数目 for i = 1 : 1 : size(a, 2) - 1 if a(i) > 0 && a(i+1) ==0 num = num + 1; end end if a(end) > 0 num = num + 1; end block_num = num; end % end function
完
各美其美,美美与共,不和他人作比较,不对他人有期待,不批判他人,不钻牛角尖。
心正意诚,做自己该做的事情,做自己喜欢做的事情,安静做一枚有思想的技术媛。
版权声明,转载请注明出处:https://www.cnblogs.com/happyamyhope/
心正意诚,做自己该做的事情,做自己喜欢做的事情,安静做一枚有思想的技术媛。
版权声明,转载请注明出处:https://www.cnblogs.com/happyamyhope/