필터 지우기
필터 지우기

How do I use NCWRITE to write an entire variable?

조회 수: 3 (최근 30일)
chaos4u2
chaos4u2 2013년 2월 20일
Hello, I'm working with netcdf file. I want to write a value to a variable that it's an array.
My problem is that when I do for example:
ncwrite('myfile.nc', 'variable', 2)
Value=2 of the variable. The value 2 only goes to the first position of the array variable, and what I want is to give the value 2 in all the components of the array variable.
How can I do it?

채택된 답변

Ashish Uthama
Ashish Uthama 2013년 2월 20일
편집: Ashish Uthama 2013년 2월 20일
Update your third input argument to have the same size as the variable in the file that you are writing to.
For example, if your 'variable' in 'myfile.nc' is 20x30 elements, to set all the elements to the value 2 use:
ncwrite('myfile.nc','variable', 2*ones(20,30);
You can query the current size of the variable using ncinfo :
vinfo = ncinfo('t.nc','variable');
ncwrite('t.nc','variable', 2*ones(vinfo.Size));
  댓글 수: 1
chaos4u2
chaos4u2 2013년 2월 22일
Thank you Ashish, you're the best!!!!! You really solved my problem fast and easy!! I'm very grateful!!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 NetCDF에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by