www.gusucode.com > datastoreio工具箱 matlab源码程序 > datastoreio/+matlab/+io/+datastore/@SpreadsheetDatastore/reset.m
function reset(ds) %RESET Reset the SpreadsheetDatastore to the start of the data. % RESET(SSDS) resets SSDS to the beginning of the datastore. % % Example: % -------- % % Create a SpreadsheetDatastore % ssds = spreadsheetDatastore('airlinesmall_subset.xlsx') % % We are only interested in the Arrival Delay data % ssds.SelectedVariableNames = 'ArrDelay' % ssds.ReadSize = 'sheet'; % [tab,info] = read(ssds); % % Since reading from the datastore above affected the state % % of ssds, reset to the beginning of the datastore: % reset(ssds) % % Sum the Arrival Delays % sumAD = 0; % while hasdata(ssds) % tab = read(ssds); % data = tab.ArrDelay(~isnan(tab.ArrDelay)); % filter data % sumAD = sumAD + sum(data); % end % sumAD % % See also - matlab.io.datastore.SpreadsheetDatastore, read, readall, hasdata, preview. % Copyright 2015 The MathWorks, Inc. try reset@matlab.io.datastore.FileBasedDatastore(ds); catch ME throw(ME); end % reset the sheets to read index and set state to signify that there is % no data available to convert. ds.SheetsToReadIdx = 1; ds.IsDataAvailableToConvert = false; ds.NumRowsAvailableInSheet = 0; end