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
Elimelech Schreiber
2020년 12월 9일
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
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
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 Center 및 File Exchange에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!