keys
说明
示例
查询字典的键
创建一个包含三个键-值对组的字典,这些对组将数字映射到字符串。
names = ["Unicycle" "Bicycle" "Tricyle"]; wheels = [1 2 3]; d = dictionary(wheels,names)
d = dictionary (double --> string) with 3 entries: 1 --> "Unicycle" 2 --> "Bicycle" 3 --> "Tricyle"
使用 keys
返回一个包含字典中存储的键的数组。
k = keys(d)
k = 3×1
1
2
3
以元胞数组形式返回字典的键
创建一个包含三个键-值对组的字典,这些对组将数字映射到字符串。
names = ["Unicycle" "Bicycle" "Tricyle"]; wheels = [1 2 3]; d = dictionary(wheels,names)
d = dictionary (double --> string) with 3 entries: 1 --> "Unicycle" 2 --> "Bicycle" 3 --> "Tricyle"
使用 keys
和可选输入 "cell"
返回一个数组,该数组包含作为元胞数组存储在字典中的键。
k = keys(d,"cell")
k=3×1 cell array
{[1]}
{[2]}
{[3]}
输入参数
d
— 字典
dictionary
对象
字典,指定为 dictionary
对象。如果 d
未配置,keys
将引发错误。
版本历史记录
在 R2022b 中推出
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)