Effacer les filtres
Effacer les filtres

Adding input arguments to datastore

1 vue (au cours des 30 derniers jours)
Collin Tuttle
Collin Tuttle le 19 Juin 2017
Commenté : Collin Tuttle le 19 Juin 2017
I am trying to use ncread in conjunction with a datastore, but I do not know how to add a variable name as an input argument. I've been trying this, but I can't figure out how to have it select a variable name. Thanks!
ds = datastore('filename.nc', 'Type', 'file', 'ReadFcn', @ncread);
T = tall(ds);

Réponse acceptée

Steven Lord
Steven Lord le 19 Juin 2017
varname = 'peaks';
myReadFcn = @(filename) ncread(filename, varname);
ds = datastore('example.nc', 'Type', 'file', 'ReadFcn', myReadFcn);
T = tall(ds);
You could of course combine those four lines into one, but I kept them as four separate lines to make it easier to understand each piece. This also assumes example.nc contains a variable named peaks.

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by