www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/ReadDataInTabularTextDatastoreExample.m
%% Read Data in TabularTextDatastore %% % Create a datastore from the sample file, |airlinesmall.csv|, which % contains tabular data. ds = tabularTextDatastore('airlinesmall.csv','TreatAsMissing','NA','MissingValue',0); %% % Modify the |SelectedVariableNames| property % to specify the variables of interest. ds.SelectedVariableNames = {'DepTime','ArrTime','ActualElapsedTime'}; %% % While there is data available to be read from the datastore, read one % block of data at a time and analyze the data. In this example, sum the % actual elapsed time. sumElapsedTime = 0; while hasdata(ds) T = read(ds); sumElapsedTime = sumElapsedTime + sum(T.ActualElapsedTime); end %% % View the sum of the actual elapsed time. sumElapsedTime