How would I recode this MatLab code into Gauss? I am interested in coding for the nested IF statements.

MatLab:

for i=1:5000 for t=4:15 %The fourth month here is the first of the 12 months if IOFC(i,t-3) <=6 if IOFC(i,t-2) <=6 phi(i,t)=1; else phi(i,t)=0; end elseif IOFC(i,t-2)<=4 phi(i,t)=1; else phi(i,t)=0; end end end

## 1 Answer

0

I am assuming that the IOFC references in the Matlab code are indexing into matrices. If they are actually function calls, replace "IOFC[i, t-3]" with "IOFC(i, t-3)".

for i(1, 5000, 1); for t(4, 15, 1); if IOFC[i, t-3] ≤ 6; if IOFC[i, t-2] ≤ 6; phi[i, t] = 1; else; phi[i, t] = 0; endif; elseif IOFC[i, t-2] ≤ 4; phi[i, t] = 1; else; phi[i, t] = 0; endif; endfor; endfor;

The main differences are that in GAUSS, `if` statements end with `endif` and `for` statements are ended with `endfor`. Also, `for` loops have the syntax:

for counter(start, stop, increment);

compared to:

for counter=start:end