How to built vocabulary of numeric words comprised of cells?
1 view (last 30 days)
Show older comments
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 Comments
Elimelech Schreiber
on 9 Dec 2020
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:
Answers (1)
Walter Roberson
on 9 Dec 2020
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 Comments
Walter Roberson
on 9 Dec 2020
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) ?
See Also
Categories
Find more on Data Import and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!