count_num.m

来自「802.11仿真源码 对分析RSSI很有用的」· M 代码 · 共 22 行

M
22
字号
function [First, Last] = Count_num(array, int)
% Given an array and an integer, this function returns the first occurance 
% of that integer and the number of integers that occur within the array

count = 0;
i = 1;
initial = 0;
first = 0;

while(i<=length(array)) 
    if(array(i) == int)
        count = count + 1;
        if(initial == 0)
            first = i;
            initial = 1;
        end
    end
    i = i + 1;
end

First = first;        
Last = count + first - 1;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?