フィルターのクリア

How to break a large table into a set of smaller tables?

4 ビュー (過去 30 日間)
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2020 年 1 月 31 日
コメント済み: Walter Roberson 2020 年 1 月 31 日
This question is asked before and my problem is that the one of the columns are string not numbers and I recieve this error "Error using ==
Comparison between double and string is not supported." when using this code taken from the answers to the above question:
col24 = T{:,[27 28]};
u24 = unique(col24, 'rows');
numentry = size(u24,1);
TableCell = cell(numentry,1);
for K = 1 : numentry
insubset = T{:,27} == u24(K,1) && T{:,28} == u24(K,2);
TableCell{K} = BigTable(insubset,:);
end
Alos is it possible to use the name of columns instead of numnber so instead of 27 and 28 which are the column number in col24 = T{:,[27 28]}; use the name of those columns?
  2 件のコメント
Walter Roberson
Walter Roberson 2020 年 1 月 31 日
col24 = T{:, {'x', 'y'}};
would be an example of extracting by variable names x and y.
Would I be correct is saying that one of the variables is string datatype and the other variable is numeric ?
Mohammad Sami
Mohammad Sami 2020 年 1 月 31 日
For string datatype, using functions such as contains, startsWith, endsWith for comparison.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2020 年 1 月 31 日
col24 = T(:,[27 28]); %notice () not {} . Output is table
u24 = unique(col24, 'rows'); %output is table
numentry = size(u24,1);
TableCell = cell(numentry,1);
for K = 1 : numentry
insubset = strcmp(T{:,27},u24{K,1}) & T{:,28} == u24{K,2}; %notice {} not ()
TableCell{K} = T(insubset,:);
end
Note: this code should work even if column 27 is cell array of character vector instead of string data type. If you are sure you will have string() datatype then
insubset = T{:,27} == u24{K,1} & T{:,28} == u24{K,2};
will also work.
  4 件のコメント
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2020 年 1 月 31 日
By the way waht is TableCell? Is it cell array?
How can I convert that to TableCell to individual tables?
Walter Roberson
Walter Roberson 2020 年 1 月 31 日
TableCell is a cell array that contains tables. You can use TableCell{1}, TableCell{2} and so on to extract the individual tables. You would not assign them to individual variables because you do not know how many there are. http://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval

サインインしてコメントする。

その他の回答 (1 件)

Zeynab Mousavikhamene
Zeynab Mousavikhamene 2020 年 1 月 31 日
@Walter Roberson
Yes onn of the columns of table are string (column 27) the other is numeric.

カテゴリ

Help Center および File ExchangeTables についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by