countele.m
资源名称:speech.rar [点击查看]
上传用户:ay_070428
上传日期:2014-12-04
资源大小:11427k
文件大小:1k
源码类别:
语音合成与识别
开发平台:
Matlab
- function [sorted_element, element_count] = countele(in)
- %COUNTELE Count elements in a vector.
- % Type "countele" for a self demo.
- % Roger Jang, 3-27-1997
- if nargin==0, selfdemo; return, end
- [m,n] = size(in);
- in1 = sort(in(:)');
- in1 = [in1 in1(length(in1))+1];
- index = find(diff(in1) ~= 0);
- sorted_element = in1(index);
- element_count = diff([0, index]);
- if n == 1,
- sorted_element = sorted_element';
- element_count = element_count';
- end
- % ====== Seld demo ======
- function selfdemo
- in = [5 3 3 2 1 5 5 3 4 7 20 20 20];
- fprintf('The input vector "in" isn');
- for i = 1:length(in),
- fprintf('%g ', in(i));
- end
- fprintf('nn"[sorted_element, element_count] = countele(in)" produces the following output:n');
- [sorted_element, element_count] = countele(in)