tallArray sorting and plot error

2 vues (au cours des 30 derniers jours)
Yu Jia
Yu Jia le 21 Mai 2019
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_);

Réponses (1)

Rick Amos
Rick Amos le 28 Mai 2019
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_);

Catégories

En savoir plus sur Large Files and Big Data dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by