Re: Help Calling Java from Matlab

At BODC we use Matlab and Java in combination although we tend to use the f
ormer for data processing and the latter for visualisation.

1) It may be worth mentioning that there is a NetCDF toolbox which uses MEX
 files. So this is the non-Java way to write NetCDF from Matlab. See the Un
idata web site.

Sticking with the Java approach.
2)   Minor point but rather than tweaking the classpath use the dynamic jav
aaddpath. 
3)  The manual looks to be out of date because I remember converting ArrayA
bstract to Array very recently. The code we use to write variables in Java
looks like this.

          String chanam  =  ch.getChannelName(true);  // variable name

           switch(ch.getType()){
           case 'I':
             aa  =  Array.factory(int.class, ch.getShape(),     // getSha
pe is the array of Dimensions
                     ch.getDataInt());
   // The data array
             break;
           case 'D':
             aa  =  Array.factory(double.class, ch.getShape(),
                      ch.getDataDouble(false));
             break;
           case 'F':
             aa  =  Array.factory(float.class, ch.getShape(),
                     ch.getDataFloat(false));
             break;
           default: throw new RuntimeException("Unrecognised type");
           }
        qxffile.write(chanam,aa); //qxffile will be the NetcdfFileWriteable

This can be carried over to Matlab very easily.

Steve Loch.
BODC

>>> "Rich Signell" <rsignell@xxxxxxxx> 09/07/2007 15:50 >>>
Roger,

I haven't tried to write files from Matlab using NetCDF Java, but here
is an example of a Matlab using some of the higher level functionality
within NetCDF-Java to access and plot an isosurface from a 3D
dimensionless vertical coordinate ocean model:

http://stellwagen.er.usgs.gov/rps/share/java_isosurface_demo2.m 

If you follow the instructions carefully at the top of the m-file to
download the .jar file and edit the classpath, it should just work for
you, as it accesses the model data via OpenDAP, which is supported by
NetCDF-Java.

Let me know if it doesn't work.

-Rich

On 7/9/07, Roger GALLOU (AGO) <roger.gallou@xxxxxx> wrote:
> Hello,
>
> I hope I'm on the good users list.
> I'm working  with Matlab R2006b on Windows. I 'm intesresting by the
> NetCDF Java package to access to data files for read and write.
> I've found some examples, I try on Matlab, in the document : NetCDF Java
> Users' Manuel (page 33-34).
>
> I need some help to call some classes of the librairy nc2.2.jar,
> particulary for writing files :
> all the classes type ArrayInt (Double, ...) for dimensions D1, D2, D3 ...
>
> I success to manage dimension, attribut, but I don't manage to create a
> array of data for any dimension I know.
> In Matlab, the instruction :
> ucar.ma2.ArrayInt.D3(2, latDim.getLength(), lonDim.getLength()) answers
> that the method D3 doesn't exist.
> I can't call with the "$" character as it is declared in the package
> ucar.ma2.
> (ex : ArrayInt$D1).
>
> Is there anybody who have encounter this king of problem ? If yes, could
> he/she bring me some help ?
> In extension, if anybody has some informations for writing NetCDF files
> with Java librairies in Matlab, I'm interesting.
>
> Thanks by advance.
>
> Roger GALLOU
> roger.gallou@xxxxxx 
> 02 98 05 43 21 (FRANCE)
>
>
>
> ========================
=========================
=========================
=====
> To unsubscribe netcdf-java, visit:
> http://www.unidata.ucar.edu/mailing-list-delete-form.html 
> ========================
=========================
=========================
=====
>


-- 
Dr. Richard P. Signell   (508) 457-2229
USGS, 384 Woods Hole Rd.
Woods Hole, MA 02543-1598

=========================
=========================
=========================
====
To unsubscribe netcdf-java, visit:
http://www.unidata.ucar.edu/mailing-list-delete-form.html 
=========================
=========================
=========================
====



-- 
This message (and any attachments) is for the recipient only. NERC
is subject to the Freedom of Information Act 2000 and the contents
of this email and any reply you make may be disclosed by NERC unless
it is exempt from release under the Act. Any material supplied to
NERC may be stored in an electronic records management system.

=============================================================================To 
unsubscribe netcdf-java, visit:
http://www.unidata.ucar.edu/mailing-list-delete-form.html
=============================================================================

  • 2007 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: