setcats
设置分类数组中的类别
说明
示例
设置新类别
创建包含各种颜色的分类数组。
A = categorical({'blue','black','red';'red','blue','black';'black','red','blue'})
A = 3x3 categorical
blue black red
red blue black
black red blue
设置新类别。
B = setcats(A,{'red','black'})
B = 3x3 categorical
<undefined> black red
red <undefined> black
black red <undefined>
A
中颜色为 blue
的元素未在 B
中定义。
设置新类别并分配元素
创建包含各种颜色的分类数组。
A = categorical({'blue','black','red';'red','blue','black';'black','red','blue'})
A = 3x3 categorical
blue black red
red blue black
black red blue
设置新类别。包括不是 A
中类别的类别。
B = setcats(A,{'red','pink','blue'})
B = 3x3 categorical
blue <undefined> red
red blue <undefined>
<undefined> red blue
B
的元素都不为 pink
,因为 pink
不是 A
的类别。将 B
的一个元素分配为 pink
。
B(1,2) = 'pink';
B
B = 3x3 categorical
blue pink red
red blue <undefined>
<undefined> red blue
输入参数
A
— 分类数组
向量 | 矩阵 | 多维数组
分类数组,指定为向量、矩阵或多维数组。
newcats
— 新类别
字符向量 | 字符向量元胞数组 | 字符串数组
新类别,指定为字符向量、字符向量元胞数组或字符串数组。
提示
要更改分类数组中的类别名称,请使用
renamecats
。
扩展功能
tall 数组
对行数太多而无法放入内存的数组进行计算。
此函数完全支持 tall 数组。有关详细信息,请参阅 tall 数组。
C/C++ 代码生成
使用 MATLAB® Coder™ 生成 C 代码和 C++ 代码。
基于线程的环境
使用 MATLAB® backgroundPool
在后台运行代码或使用 Parallel Computing Toolbox™ ThreadPool
加快代码运行速度。
此函数完全支持基于线程的环境。有关详细信息,请参阅在基于线程的环境中运行 MATLAB 函数。
分布式数组
使用 Parallel Computing Toolbox™ 在集群的组合内存中对大型数组进行分区。
此函数完全支持分布式数组。有关详细信息,请参阅Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox)。
版本历史记录
在 R2014b 中推出
另请参阅
categories
| removecats
| iscategory
| mergecats
| renamecats
| reordercats
| addcats
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)