How to built vocabulary of numeric words comprised of cells?

2 次查看(过去 30 天)
I have two different variables. First variable is comprised of 104x1 cells and second variable is comprised of 160x240 cells. I have to develop a dictionary that contains both of these variables. How should I do it? I have move through different tutorials of building dictionary, but I cannot understand.
Kindly guide me How do I do it?
  3 个评论
Sameema Tariq
Sameema Tariq 2020-12-9
Basically I am working on image processing, processing each frame gives me two variable as mentioned above. I have two add these variables in dictionary in such a way that these variable are only stored in it without any key values. So I dont want any dictionary-like data structure. I hope so I cleared my point.
Elimelech Schreiber
You are very unclear about your problem.
I think you are simply trying to combine these two variables into one structure, in which case either use a cell array, or a strcture.
a = ones(104, 1);
b = ones(160, 240);
c = {a, b}; % - cell array
d = struct('a', a, 'b', b) % - structure
learn more about these data constructs here:

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2020-12-9
uniquevars = unique([First{:}; Second{:}]);
This will just be a list of the all of the values that occur, without there being any dictionary data structure involved.
  2 个评论
Sameema Tariq
Sameema Tariq 2020-12-9
This command pass me an error as:
Dimensions of matrices being concatenated are not consistent
As my first variable has size 104x1 cells while other is 160x240 cells.
I have to build up a dictionary where I can store these two variables. If you have anyother solution, do share.
Thanks
Walter Roberson
Walter Roberson 2020-12-9
First_vec = cellfun(@(v) v(:), First, 'uniform', 0);
Second_vec = cellfun(@(v) v(:), Second, 'uniform', 0);
uniquevars = unique([First_vec{:}; Second_vec{:}]);
I have to build up a dictionary where I can store these two variables.
You specifically told us earlier "So I dont want any dictionary-like data structure", and "in such a way that these variable are only stored in it without any key values", so we are led to believe that you simulateneously want a dictionary and specifically do not want a dictionary.
Suppose that all of the cells are examined and the unique values over all of the cells are found, and suppose there are 583 of them. Now consider the 309'th of those unique values. Do you need to be able to pass in that 309'th value and use it to retrieve some associated data? Do you need to be able to pass in (something else) and use it to retrieve that 309'th value? Are the values being extracted to be used as the keys or as the data associated with the keys? Or is the data just implied, such as building a spell checking system in which at any point want you want to know is "Is this a known word?" (is the word present in the list of known words, or not present) ?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Import and Analysis 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by