ncwriteschema - assign variables and Dimensions to variables
조회 수: 1 (최근 30일)
이전 댓글 표시
I really need help with netCDF Schemas.
I would like to export data and therefor create a netCDF-Schema.
This works:
mySchema.Name = '/';
mySchema.Format = 'classic';
mySchema.Dimensions(1).Name = 'rows';
mySchema.Dimensions(1).Length = length([1 2 3 4 5 6 7]');
mySchema.Dimensions(1).Name = 'columns';
mySchema.Dimensions(1).Length = 1;
ncwriteSchema('Testfile',mySchema)
But when trying to add Variables and try to assign Dimensions to the Variables i get an error:
mySchema.Name = '/';
mySchema.Format = 'classic';
mySchema.Dimensions(1).Name = 'rows';
mySchema.Dimensions(1).Length = 7;
mySchema.Dimensions(1).Name = 'columns';
mySchema.Dimensions(1).Length = 1;
mySchema.Variables(1).Name = 'r0';
mySchema.Variables(1).Dimensions = {'rows' 'columns'};
mySchema.Variables(1).Datatype = 'float'
ncwriteschema('Testfile',mySchema)
ERROR:
Attempt to reference field of non-structure array.
Error in internal.matlab.imagesci.nc/writeDimensionSchema (line 1483)
dimNames = {schema.Name};
Error in internal.matlab.imagesci.nc/writeVariableSchema (line 1582)
this.writeDimensionSchema(...
Error in internal.matlab.imagesci.nc/writeGroupSchema (line 1676)
this.writeVariableSchema(schema.Variables, schema.Name);
Error in internal.matlab.imagesci.nc/writeSchema (line 490)
this.writeGroupSchema(schema);
Error in ncwriteschema (line 91)
ncObj.writeSchema(schemastruct);
QUESTION:
I really need help to add the Variables correctly to the netCDF Schema. I hope you guys know an answer.
I think it has something to do with this line:
mySchema.Variables(1).Dimensions = {'rows' 'columns'};
PS: I searched for solutions in MATLAB help and google yet.
댓글 수: 2
Ashish Uthama
2012년 6월 21일
Clemens, you can 'accept' Johns answer if it works for you. That way we know this question is 'solved' :)
채택된 답변
John
2012년 6월 20일
The specification for the variable dimensions should be the same as in the dimensions themselves, i.e. just listing the dimension names isn't enough. Rewrite as
mySchema.Name = '/';
mySchema.Format = 'classic';
mySchema.Dimensions(1).Name = 'rows';
mySchema.Dimensions(1).Length = 7;
mySchema.Dimensions(2).Name = 'columns';
mySchema.Dimensions(2).Length = 1;
mySchema.Variables(1).Name = 'r0';
mySchema.Variables(1).Dimensions(1) = mySchema.Dimensions(1); % rows
mySchema.Variables(1).Dimensions(2) = mySchema.Dimensions(2); % cols
mySchema.Variables(1).Datatype = 'single';
ncwriteschema(ncfile,mySchema)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import and Analysis에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!