I have a set in MATLAB that I want to export it to GAMS and the order of elements in the set is important to me. As I know, the order that I define the set for the first time is the order that is defined for GAMS.
As an example, I have the below code in MATLAB:
Is.name=‘i’;
Is.type=‘set’;
Is.val=[3;2;1];
Is.dim=1;
wgdx(‘data’,Is)

And the following code is in GAMS:
$GDXIN ‘data’
Sets
i ;
$load i
$GDXIN

display i;

but the output for i is 1,2,3. but I want the order be 3,2,1.
the gdx file is attached. data.gdx (397 Bytes)

At the start of your GAMS-code you could define a set that orders set elements (eg "set setord /3,2,1/;), this way every time these set-elements will be presented they will be ordered this way.
Downside is that you have to update this setord-list if your set-elements change…

I assume you mean your algorithm in Matlab? I’m sure Matlab has some functionality to write .txt-files in which you could put the right set order after the algorithm is finished. Then you can include that file in your GAMS code to use this set order.