I want to export my variabels to a single .nc file
Hello.
I have a set of variables that i want to export as one .nc file so that i can use the dataset later on. I have tried using the instructions listed in this thread but it keeps returning an error. I’ll include my code and the variables that i use below. And sorry for the rudamentary code, I’m still new to matlab
clear
clc
%masukin waktu
waktu= ncread(‘FABMSAT.nc’,’time’);
waktu= waktu’;
%masukin fito layer 1
fito= ncread(‘FABMSAT.nc’,’npzd_phy’);
fito= fito(:,1,:);
%masukin pasut
pasut= ncread(‘FABMSAT.nc’,’zeta’);
% masukin vector u
u= ncread(‘FABMSAT.nc’,’u’);
u= u(:,1,:);
%Masukin vector v
v= ncread(‘FABMSAT.nc’,’u’);
v= v(:,1,:);
%CUT SUPAYA MULAI 1 FEB 2022
waktu_feb= waktu;
waktu_feb(:,[1:168])=[];
fito_feb= fito;
fito_feb(:,[1:168])=[];
pasut_feb= pasut;
pasut_feb([2:8307],:)=[];
u_feb= u;
u_feb(:,[1:168])=[];
v_feb= v;
v_feb(:,[1:168])=[];
%define dimensions
netcdf.setDefaultFormat(‘NC_FORMAT_CLASSIC’);
ncid = netcdf.create(‘test.nc’,’NC_WRITE’);
dimidfito = netcdf.defDim(ncid,’fito_feb’,fito_feb);
%Define the name of variable
var_fito = netcdf.defVar(ncid, ‘fito_feb’,’NC_FLOAT’,[dimidfito]);
%variables into .nc file
netcdf.endDef(ncid);
netcdf.putVar(ncid,var_fito,fito_feb);
netcdf.close(ncid);Hello.
I have a set of variables that i want to export as one .nc file so that i can use the dataset later on. I have tried using the instructions listed in this thread but it keeps returning an error. I’ll include my code and the variables that i use below. And sorry for the rudamentary code, I’m still new to matlab
clear
clc
%masukin waktu
waktu= ncread(‘FABMSAT.nc’,’time’);
waktu= waktu’;
%masukin fito layer 1
fito= ncread(‘FABMSAT.nc’,’npzd_phy’);
fito= fito(:,1,:);
%masukin pasut
pasut= ncread(‘FABMSAT.nc’,’zeta’);
% masukin vector u
u= ncread(‘FABMSAT.nc’,’u’);
u= u(:,1,:);
%Masukin vector v
v= ncread(‘FABMSAT.nc’,’u’);
v= v(:,1,:);
%CUT SUPAYA MULAI 1 FEB 2022
waktu_feb= waktu;
waktu_feb(:,[1:168])=[];
fito_feb= fito;
fito_feb(:,[1:168])=[];
pasut_feb= pasut;
pasut_feb([2:8307],:)=[];
u_feb= u;
u_feb(:,[1:168])=[];
v_feb= v;
v_feb(:,[1:168])=[];
%define dimensions
netcdf.setDefaultFormat(‘NC_FORMAT_CLASSIC’);
ncid = netcdf.create(‘test.nc’,’NC_WRITE’);
dimidfito = netcdf.defDim(ncid,’fito_feb’,fito_feb);
%Define the name of variable
var_fito = netcdf.defVar(ncid, ‘fito_feb’,’NC_FLOAT’,[dimidfito]);
%variables into .nc file
netcdf.endDef(ncid);
netcdf.putVar(ncid,var_fito,fito_feb);
netcdf.close(ncid); Hello.
I have a set of variables that i want to export as one .nc file so that i can use the dataset later on. I have tried using the instructions listed in this thread but it keeps returning an error. I’ll include my code and the variables that i use below. And sorry for the rudamentary code, I’m still new to matlab
clear
clc
%masukin waktu
waktu= ncread(‘FABMSAT.nc’,’time’);
waktu= waktu’;
%masukin fito layer 1
fito= ncread(‘FABMSAT.nc’,’npzd_phy’);
fito= fito(:,1,:);
%masukin pasut
pasut= ncread(‘FABMSAT.nc’,’zeta’);
% masukin vector u
u= ncread(‘FABMSAT.nc’,’u’);
u= u(:,1,:);
%Masukin vector v
v= ncread(‘FABMSAT.nc’,’u’);
v= v(:,1,:);
%CUT SUPAYA MULAI 1 FEB 2022
waktu_feb= waktu;
waktu_feb(:,[1:168])=[];
fito_feb= fito;
fito_feb(:,[1:168])=[];
pasut_feb= pasut;
pasut_feb([2:8307],:)=[];
u_feb= u;
u_feb(:,[1:168])=[];
v_feb= v;
v_feb(:,[1:168])=[];
%define dimensions
netcdf.setDefaultFormat(‘NC_FORMAT_CLASSIC’);
ncid = netcdf.create(‘test.nc’,’NC_WRITE’);
dimidfito = netcdf.defDim(ncid,’fito_feb’,fito_feb);
%Define the name of variable
var_fito = netcdf.defVar(ncid, ‘fito_feb’,’NC_FLOAT’,[dimidfito]);
%variables into .nc file
netcdf.endDef(ncid);
netcdf.putVar(ncid,var_fito,fito_feb);
netcdf.close(ncid); export, netcdf MATLAB Answers — New Questions