我containers.map
在 MATLAB 中使用 hashtable ( ),现在我想用该信息创建一个矩阵。因此,当我运行我的哈希表,然后为每种类型插入我的文本文件时,我会在命令窗口中看到类似这样的内容:
编辑
F = listdlg('PromptString','Different types', 'SelectionMode',...
'single', 'ListString',E, 'Name','Select a type','ListSize',[230 130]);
[files,path] = uigetfile ('*.txt','Select your text files',...
'MultiSelect','on');
whereE
只是用户的输入,在这种情况下是pink
,purple
和yellow
。
%save for each type the user enters the corresponding text files he
%wants to train
%A Map object is a data structure that allows you to retrieve values
%using a corresponding key. Keys can be real numbers or text strings
%and provide more flexibility for data access than array indices,
%which must be positive integers. Values can be scalar or nonscalar arrays.
handles.map (E(F,:)) = files;
handles.map
a = handles.map.values
b = handles.map.keys
handles.map.size
b =
{1x3 cell} {1x6 cell} {1x4 cell}
a =
'pink ' 'purple' 'yellow'
所以我现在想将总数b
作为矩阵上的行数m
;所以总行数为 14 并且每一位从a
成为一列;所以一共有3列。但我想创建一个二进制矩阵,其中每列将标识不同的类型。最后,我将创建一个这样的矩阵:
m =[1 0 0
1 0 0
1 0 0
0 1 0
0 1 0
0 1 0
0 1 0
0 1 0
0 1 0
0 0 1
0 0 1
0 0 1
0 0 1];
Where the first 3 rows of the matrix says that there are 3text files of type pink
, the next 6 rows : 6 text files of type purple
and the last 4: 4 text files of type yellow
.
I hope that now is more clear. :)
Any help would be appreciated! :) x