Use a numeric array as Map value

조회 수: 2 (최근 30일)
Ben
Ben 2015년 7월 19일
댓글: Ben 2015년 7월 22일
I'm reading through a file and want to create a map of string keys, each with an array of numeric arrays. How do I go about declaring this object and then appending arrays to the values?
  댓글 수: 1
Cedric
Cedric 2015년 7월 19일
편집: Cedric 2015년 7월 19일
Can you give an example?

댓글을 달려면 로그인하십시오.

답변 (1개)

Cedric
Cedric 2015년 7월 19일
편집: Cedric 2015년 7월 19일
If I understand well what you are trying to achieve, you can:
  • Build your own system using a cell array of keys and STRCMP/STRCMPI/REGEXP for matching key/value pairs.
  • Use a containers.Map object.
  • Use a Java Hashtable object ( java.util.Hashtable )
Note that if you need to store complex data structures, a good option is to use a hybrid approach, where you define a values cell array, a keys hashtable, and then store complex data structures in the cell array and only their IDs in the hashtable.
  댓글 수: 5
Cedric
Cedric 2015년 7월 20일
편집: Cedric 2015년 7월 20일
If all you need to implement is this Python-dict-like feature, yes. But if you really have to iterate through files and then use MATLAB for performing some type of processing, then you should stick to MATLAB. The last two mechanisms that I mention are close to Python dictionary objects; learning to use them is much easier than interfacing Python and MATLAB.
Ben
Ben 2015년 7월 22일
Eh, in the end it was easy enough just to save the relevant information to files with Python, then process it further in Matlab.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Python Package Integration에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by