tallArray sorting and plot error

2 ビュー (過去 30 日間)
Yu Jia
Yu Jia 2019 年 5 月 21 日
回答済み: Rick Amos 2019 年 5 月 28 日
Issue description:
I converted a large amount of files into .mat files and create datastore and tallArray to make some plots. What I would like to do is to create a tallArray and trim the data to only have the rows and columns that I need and plot them.
Matlab script
clear all;
fileToPlot = '12C_011_Matfiles';
parentpath = 'You can just put a directoray here to /12C Mat files/';
% Create tall array of the fileToPlot
ds = datastore(strcat(parentpath, fileToPlot));
tallArray = tall(ds);
% Only get the two columns of data and rows when the two conditions tallArray.State='D' and tallArray.ES>1 are both met.
tt.Cycles = gather([tallArray.State{:}] == 'D' & tallArray.ES>1, tallArray.Cyc_);
tt.DchAh = gather([tallArray.State{:}] == 'D' & tallArray.ES>1, tallArray.Amp_hr);
% Plot the figure only for the cycles <=200
figure (1)
plot(Cycles<=200,DchAh)
Error:
Indexing expressions of the form T{...,...} are not supported for tall arrays.
when I changed the code from
tt.Cycles = gather([tallArray.State{:}] == 'D' & tallArray.ES>1, tallArray.Cyc_);
to
tt.Cycles = gather(tallArray.State(:) == 'D' & tallArray.ES>1, tallArray.Cyc_);
I got new errors below:
Undefined operator '==' for input arguments of type 'cell'.
Error in ==
Error in CL_plots_NJ (line 9)
tt.Cycles = gather(tallArray.State(:) == 'D' & tallArray.ES>1, tallArray.Cyc_);
Error in tall/gather (line 50)
[varargout{:}, readFailureSummary] = iGather(varargin{:});
Error in CL_plots_NJ (line 9)
tt.Cycles = gather(tallArray.State(:) == 'D' & tallArray.ES>1, tallArray.Cyc_);

回答 (1 件)

Rick Amos
Rick Amos 2019 年 5 月 28 日
Instead of converting State to a character vector, I would recommend using one of the string utilities. These are all supported by tall array:
tt.Cycles = gather(strcmp(tallArray.State, 'D') & tallArray.ES>1, tallArray.Cyc_);
Or, if you are using R2018b or later, you can use the string type. Strings are an improved version of cell array of character vector and support equality. To create a string as opposed to a character vector, use double quotes:
tt.Cycles = gather(tallArray.State == "D" & tallArray.ES>1, tallArray.Cyc_);

カテゴリ

Help Center および File ExchangeLarge Files and Big Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by