Main Content

countEachLabel

数数number of unique labels

描述

例子

tbl= countEachLabel(广告计算数据存储中每个唯一标签的次数。换句话说,它将每个唯一标签的文件数量计数。输出tbl是带有可变名称的表标签and数数

例子

tbl= countEachLabel(广告,“ tablevariable',变量的名称计算数据存储中每个唯一标签的次数。当数据存储时标签属性由表指定,您必须指定变量的名称变量的名称is the table variable (column) name you want to count.

例子

全部收缩

将文件路径指定到Audio Toolbox™中包含的音频样本。

文件夹= fullfile(matlabroot,'toolbox',,,,'声音的',,,,“样品”);

Create an audio datastore that points to the specified folder. Specify theLabelSource属性为foldernames,以便将与每个文件关联的标签设置为包含文件的文件夹名称。

ads = audiodatastore(文件夹,“ Labelsource”,,,,“折叠式”
ads = audioDatastore with properties: Files: { ' .../build/matlab/toolbox/audio/samples/Ambiance-16-44p1-mono-12secs.wav'; ' .../matlab/toolbox/audio/samples/AudioArray-16-16-4channels-20secs.wav'; ' .../toolbox/audio/samples/ChurchImpulseResponse-16-44p1-mono-5secs.wav' ... and 31 more } Folders: { '/mathworks/devel/bat/Bdoc22a/build/matlab/toolbox/audio/samples' } Labels: [samples; samples; samples ... and 31 more categorical] AlternateFileSystemRoots: {} OutputDataType: 'double' SupportedOutputFormats: ["wav" "flac" "ogg" "mp4" "m4a"] DefaultOutputFormat: "wav"

称呼countEachLabel要计算每个唯一标签的次数。

tbl = counteachLabel(ADS)
tbl =1×2 table标签数数_______ _____ samples 34

如果是标签音频数据存储的属性被指定为表,计数标签时必须指定表变量名称。

将文件路径指定到Audio Toolbox™中包含的音频样本。

文件夹= fullfile(matlabroot,'toolbox',,,,'声音的',,,,“样品”);

Create an audio datastore that points to the specified folder.

ads = audiodatastore(文件夹)
ADS =带有属性的Audiodatastore:文件:{'.../build/build/matlab/toolbox/audio/samples/ambiance-16-44p1-mono-12secs.wav';'.../matlab/toolbox/audio/samples/audioArray-16-16-4Channels-20secs.wav';'.../toolbox/audio/samples/churchimplesseresponse-16-44p1-mono-5secs.wav'...和31 More}文件夹:{'/Mathworks/devel/devel/bat/bdoc22a/build/build/matlab/toolbox/audio audio/samples'} nterthateFilesystemroots:{} outputdatatype:'double'标签:{} supportEd金宝appOutputputformats:[“ wav”“ flac”“ flac”“ ogg”“ ogg”“ mp4” MP4“ M4A”“ M4A”] DefaultOutputformat:dav”

文件名包含有关文件的信息。解析文件名,以收集有关文件是单声道还是立体声的信息,以及文件是否比三十秒更长。创建一个包含解析信息的表,然后设置标签音频数据存储到标签表的属性。

numFiles =元素个数(ADS.Files);numChannels =细胞(νmFiles,1); isLong = cell(numFiles,1);为了i = 1:数字如果〜Isempty(strfind(ads.files {i},,'单核细胞增多症'))numchannels {i} ='单核细胞增多症';Elseif〜Isempty(strfind(ads.files {i},,'stereo'))numchannels {i} ='stereo';别的numchannels {i} ='未知';结尾secs = str2double(regexp(ads.files {i},,' - (\ d+)secs',,,,“令牌”,,,,'一次');如果secs> 30 islong {i} = true;Elseifsecs <= 30 isLong{i} = false;别的islong {i} ='未知';结尾结尾babeltable =表(numchannels,islong,...'variablenames',,,,{'NumberOfChannels',,,,'IsLongerThan30Seconds'}); ADS.Labels = labelTable;

称呼countEachLabelon the audio datastore and specify the桌面作为数字通道。称呼countEachLabeland specify the桌面作为IsLongerThan30Seconds

countNumberOfChannelLabels = countEachLabel(ADS,'TableVariable',,,,'NumberOfChannels'
countNumberOfChannelLabels=3×2桌数字频道计数________________ _____ mono 22立体声10未知2
countDurationLabels = CountEakeLabel(广告,'TableVariable',,,,'IsLongerThan30Seconds'
countDurationLabels=3×2桌islongerthan30秒计数_______________________________错误24 true 6未知4

输入参数

全部收缩

指定广告作为一个audiodatastore目的。

标签表变量名称,指定为字符向量或字符串,对应于该表变量标签财产。

如果是标签财产的audiodatastore由表指定。

数据类型:char|细绳

输出参数

全部收缩

标签计数表,返回为两列表,包含每个标签的名称广告and the number of files associated with each label.

数据类型:table

版本历史记录

在R2018B中引入