## How to save results to a txt or xlsx file

Problems with syntax of GAMS
confused student
User
Posts: 3
Joined: 9 months ago

### How to save results to a txt or xlsx file

Hello everyone. I have solved a problem and found the fastest route to go from one point to another. However, I don't know how to save my results to later plot it with another software, like Matlab or Excel.

This is my program:

Code: Select all

``````\$set n 10
set j /0*%n%/;
sets
jlast(j)
jnotlast(j);
jlast(j)\$(ord(j)=card(j))=yes;
jnotlast(j)=not jlast(j);

scalar

w_x basicwind direction x axis   /10/
w_y basic wind direction y axis   /0/
n number of intervals /%n%/

variable
time,
u_x(j),
u_y(j),
x(j),
y(j);

positive variable
step;

equation

diffx(j),
diffy(j),
lim_control(j),
obj;

obj.. time =e= n*step;

lim_control[j].. u_x(j)*u_x(j)=e=1-u_y(j)*u_y(j);
diffx[j]\$(jnotlast(j)).. x(j+1)-x(j)=e= 0.5*(w_x*y(j+1)*y(j+1)*y(j+1)+u_x(j+1)+w_x*y(j)*y(j)*y(j)+u_x(j));
diffy[j]\$(jnotlast(j)).. y(j+1)-y(j)=e= 0.5*(u_y(j+1)+u_y(j));

y.fx('0') = 1;
y.fx('%n%') = 0;

x.fx('0') = 2.25;
x.fx('%n%') = 0;

model brahstron1 /all/;

option
nlp=ipopt;
solve brahstron1 using nlp minimize time;
``````
and this is my attempt to save the values, however, it doesn't work at all.

Code: Select all

``````file dem /output/; put dem;
put "time = ", time; put /;
loop(j, put x[j]1:n put y[j] 1:n  put /;);``````
Can someone please tell me how to save my variables?
Thank you very much.

richard
User
Posts: 23
Joined: 11 months ago