## WGDX help for newbie

Problems with modeling
yashas1354
User
Posts: 1
Joined: 10 months ago

### WGDX help for newbie

Writing a 3-dimensional table that is dynamically updated using MATLAB.

Having a table indexed over three sets (n,i,s) this is the following code that I use to write the GDX file using MATLAB:

t.name = 'SOR';
t.type = 'parameter';
t.form = 'sparse';
t.dim = 3;
t.val = [1 1 1 n.a(1,1) 1 1 2 n.a(1,2) 1 1 3 n.a(1,3) 1 1 4 n.a(1,4)
1 2 1 n.b(1,1) 1 2 2 n.b(1,2) 1 2 3 n.b(1,3) 1 2 4 n.b(1,4)
2 1 1 n.c(1,1) 2 1 2 n.c(1,2) 2 1 3 n.c(1,3) 2 1 4 n.c(1,4)
2 2 1 n.d(1,1) 2 2 2 n.d(1,2) 2 2 3 n.d(1,3) 2 2 4 n.d(1,4)];
t.uels = {p.uels, y.uels, z.uels};
wgdx('MtoG4',t);

Where the first index n runs from 1 to 2, index i runs from 1 to 2 and s runs from 1 to 4. n here is a struct that contains the values. When I run this script I get the error, .val and .dim do not match. Can anyone help correct it
Last edited by yashas1354 9 months ago, edited 2 times in total.

Renger
Posts: 299
Joined: 2 years ago

### Re: WGDX help for newbie

Hi
Could you please post a running example of the matlab code, i.e. how you generate the variable n? Don't expect people to infer parts of your code .
CHeers
Renger
____________________________________
Enjoy modeling even more: The lazy economist