createLabel
创建工程标签
说明
createLabel(
在指定类别中创建一个新标签。如果您以前通过访问 category
,newLabelName
)Categories
属性获得 Category
对象(例如使用 proj.Categories(1)
之类的语法),请使用以上语法。
示例
创建新标签
打开 Times Table App 工程。使用 currentProject
从当前加载的工程创建一个工程对象。
openExample("matlab/TimesTableProjectExample")
proj = currentProject;
获取第一个现有类别。
cat = proj.Categories(1)
cat = Category with properties: Name: "Classification" SingleValued: 1 DataType: "none" LabelDefinitions: [1×7 matlab.project.LabelDefinition]
在类别中定义一个新标签。
createLabel(cat,"Future");
创建新标签类别以指示文件所有权
打开 Times Table App 工程。使用 currentProject
从当前加载的工程创建一个工程对象。
openExample("matlab/TimesTableProjectExample")
proj = currentProject;
创建一个名为 "Engineers"
的新标签类别,用于表示工程中的文件所有权。这些标签具有用于附加字符向量数据的 char
数据类型。
createCategory(proj,"Engineers","char");
使用 findCategory
函数按名称获取新类别
engineersCategory = findCategory(proj,"Engineers");
在新类别中创建标签。
createLabel(engineersCategory,"Tom"); createLabel(engineersCategory,"Harry");
将新标签之一附加到工程中的文件。
myfile = findFile(proj,"source/timesTableGame.m"); addLabel(myfile,"Engineers","Tom");
获取该标签并添加数据。
label = findLabel(myfile,"Engineers","Tom"); label.Data = "Maintenance responsibility"; disp(label)
Label with properties: File: "C:\myProjects\examples\TimesTableApp\source\timesTableGame.m" DataType: 'char' Data: "Maintenance responsibility" Name: "Tom" CategoryName: "Engineers"
输入参数
category
— 类别
Category
对象
新标签的类别,指定为 Category
对象。通过访问 Categories
属性(使用类似 proj.Categories(1)
的语法)获取 Category
对象,或使用 findCategory
函数。要创建一个新类别,请使用 createCategory
函数。
newLabelName
— 新标签的名称
字符向量
新标签的名称,指定为字符向量。
提示
要通过一步在现有类别中创建和附加新标签,请改用
addLabel
。要创建一个新标签类别,请先使用
createCategory
。
版本历史记录
在 R2019a 中推出
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)