gdxmrw_irgdx01_init.gms : Reading data from a indexed GDX file with IRGDX

Description

Initialization: Write "irgdx01.m" and "idx1_.gdx".

When the Matlab program "irgdx01.m" is executed, it uses
IRGDX to read the data in indexed GDX file "idx1_.gdx".

Intended use: interactive Matlab session

Contributor: Toni Lastusilta


Category : GAMS Data Utilities library


Main file : gdxmrw_irgdx01_init.gms   includes :  gdxmrw_irgdx01_init.gms

$Title Reading data from a indexed GDX file with IRGDX

$ontext
Initialization: Write "irgdx01.m" and "idx1_.gdx".

When the Matlab program "irgdx01.m" is executed, it uses
IRGDX to read the data in indexed GDX file "idx1_.gdx".

Intended use: interactive Matlab session

Contributor: Toni Lastusilta

$offtext


*Write Matlab program
$onecho > irgdx01.m
% Reading data from a GAMS Data Exchange (GDX) file in Matlab.

% read symbol a0
irgdx('idx1_','a0');
a0
%  read all the symbols
irgdx('idx1_');
a1
% read all symbols into a MATLAB structure
s = irgdx('idx1_')
s_a2=s.a2

%More info
% gdxWhos('idx1_');
% gdxInfo('idx1_');

open irgdx01
$offecho

*Write GDX file
Set i /1*2/
    j /1*2/;
Parameter a0      Scalar   /2/
          a1(i)   Vector A /1   1 , 2   3/
          a2(i,j) Matix  B /1.1 50 , 1.2 50,
                            2.1 50 , 2.2 50/;
Execute_UnloadIdx "idx1_.gdx", a0,a1,a2;


*Call Matlab
$set WHICH which
$if not %system.filesys% == UNIX $set WHICH where
$call %WHICH% matlab
$ifThen errorLevel 1
$clearError
$abort.noerror 'Matlab is not available!';
$else
$call.Async matlab -r "cd %GAMS.cdir%;irgdx01" -nosplash -nodisplay
$endIf