How to built vocabulary of numeric words comprised of cells?

1 visualización (últimos 30 días)
Sameema Tariq
Sameema Tariq el 9 de Dic. de 2020
Comentada: Walter Roberson el 9 de Dic. de 2020
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 comentarios
Sameema Tariq
Sameema Tariq el 9 de Dic. de 2020
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
Elimelech Schreiber el 9 de Dic. de 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:

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 9 de Dic. de 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 comentarios
Sameema Tariq
Sameema Tariq el 9 de Dic. de 2020
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 el 9 de Dic. de 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) ?

Iniciar sesión para comentar.

Categorías

Más información sobre Structures en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by