tallArray sorting and plot error

조회 수: 1 (최근 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 CenterFile Exchange에서 Large 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