Project

General

Profile

Integrate cdo in MATLAB

Added by Greta Jäckel over 12 years ago

Hi,

I want to call cdo from MATLAB. Is it possible?
I can open cdo.exe but cannot execute commands.

Thanks for your help


Replies (4)

RE: Integrate cdo in MATLAB - Added by Ralf Mueller over 12 years ago

How do you start cdo from matlab? I created callers from ruby + python. Maybe I can put something together for matlab integration.

RE: Integrate cdo in MATLAB - Added by Greta Jäckel over 12 years ago

Thank you for your reply.

If I type: open cdo.exe the dos-window opens, but closes very fast again so that it's not possible to perform cdo commands.

I tried it with the system() and the dos() -command, but unfortunately nothing works. Maybe something with my syntax is wrong. I tried to call the cdo commands from a textfile to, e.g.: cdo sinfo test.nc in command.txt

system('cdo.exe command.txt')

but there is the error:
Use commandline option -h for help.Error (operatorInqModID) : operator missing! command.txt is a file on disk!

ans =

1

RE: Integrate cdo in MATLAB - Added by Jaison-Thomas Ambadan over 12 years ago

Hi Greta,

You may try like this: for example if you have an input data, say temperature at pressure levels and you want to load 850hPa to a variable in Matlab, you can use (in Linux):

[status, result]=system('cdo -outputf,%13.8f,1 -sellevel,85000 input_file');

the "result" variable will contain the required output data. It should work in the same way in Windows as well.

The input_file must be either GRIB/NC or any other file format supported by CDO.

Cheers,
J.

PS: I guess this procedure is similar to any other programming language system calls. You can also call linux/windows system commands as well.

RE: Integrate cdo in MATLAB - Added by Patricia Handmann about 10 years ago

Hi,

I have another question for the integration of cdo in Matlab.

I am trying to cut out areas in several files. the area stays the same and is defined by 4 points x1,x2,y1,y2.
I am now generating a list of files that have to be cut in matlab
and work on them file by file.
The core ist this loop:

for i=1:length(files)
fname=[folder '/' files{i}];
system('cdo -selindexbox,x1,x2,y1,y2 fname /home/${fname}_new.nc');
end

So basically Matlab should hand the variables and the fame over.
Is this possible?

Cheers,
Patricia

    (1-4/4)