如何在MATLAB中使用哈希表(字典)? [英] How to use Hash Tables (dictionaries) in MATLAB?

查看:110
本文介绍了如何在MATLAB中使用哈希表(字典)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要按字符串索引访问数据,例如 table('one')%returns 1 . MATLAB中是否有这样的数据结构?如何实施?

I need to acces data by string index, like table('one') %returns 1. Is there such a data structure in MATLAB? How is it implemented?

推荐答案

在最新版本的MATLAB中,存在containers.Map数据结构.有关更多信息,请参见 MATLAB地图容器.这消除了使用STRUCT时的一些限制.例如

In recent versions of MATLAB, there's the containers.Map data structure. See MATLAB Map containers for more. This removes some of the restrictions when using STRUCTs. For example

c = containers.Map
c('foo') = 1
c(' not a var name ') = 2
keys(c)
values(c)

这篇关于如何在MATLAB中使用哈希表(字典)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆