I've been making some old fortran code into matlab langauge and I cant work out how to get round my problem.
I present the code below, it is obvious to see where the GOTO is used. Can anyone help?
for J = IN2F:IN2L;
1
B = H2(J) - H1(K);
if abs(B)<0.1*10^-7;
W2(J) = W1(K);
elseif (B<0) && (K==1) | (B>0) && (K==N1);
W2(J) = 0.0;
elseif B<0;
W2(J)=W1(K-1) + (W1(K)-W1(K-1))*((H2(J)-H1(K-1))./(H1(K)-H1(K-1)));
else
K = K + 1;
GOTO 1
end
end
I've trawelled over the net but not found any sucessful solution yet, so any input would be welcomed.
Thanks in advance
Liam
The solution is to find out what the function does and
program it in the language of your choise. One place
to start might be a text on assembler programming, where
one still uses the old GOTO type constructs to implement
stuff like for loops, while lopps and conditional branching.
Once you know the generic patterns you *might* have a
chance to decode code like the one you posted.
Rune
Use RECURSION via FUNCTION, FOR, IF and BREAK.
there are probably better ways if you restructure the if statement and get rid of the infinite loop but this most closely approximates the fortran i think... not tested.
Carlos
Replace goto 1 with continue in the matlab version of your function.
Jack Walker