Goto in pascal to Matlab
Goto in pascal to Matlab
(OP)
Does anyone know how to convert this program from pascal to matlab? The goto statement is really confusing me. I just don't understand how it flows with the goto statements in there. If going to matlab cannot be explained , if I could get an explanation of what exactly this program is doing that would be great. I would really appreciate it.
Thanks, Tina
Bhigh:= 1.5E+11;
Blow := 1.5E+2;
100:
B := (Bhigh + Blow)/2.0;
w[1] := Ts; {Surface Temperature}
w[2] := (Ts-T0)/(d1*d2) + L; {Surface Temperature Slope}
y := 0.0;
repeat
If w[1] > 1.0 then begin
Blow := B;
goto 100;
end;
If w[2] < 0.0 then begin
Bhigh := B;
goto 100;
end;
Runge( Equations0, 2, 0.01, y, w );
{writeln(B:25:20,y:10:5);}
until Bhigh-Blow < 0.00000005;
Thanks, Tina
Bhigh:= 1.5E+11;
Blow := 1.5E+2;
100:
B := (Bhigh + Blow)/2.0;
w[1] := Ts; {Surface Temperature}
w[2] := (Ts-T0)/(d1*d2) + L; {Surface Temperature Slope}
y := 0.0;
repeat
If w[1] > 1.0 then begin
Blow := B;
goto 100;
end;
If w[2] < 0.0 then begin
Bhigh := B;
goto 100;
end;
Runge( Equations0, 2, 0.01, y, w );
{writeln(B:25:20,y:10:5);}
until Bhigh-Blow < 0.00000005;
RE: Goto in pascal to Matlab
Upon web search, my best guess is that Matlab doesn't support goto. As far as adapting it goes, you would probably need to supply a little more about what this code is supposed to do, along with acceptable & expected data, so any suggestion we might give you on a gotoless code could be tested.
(and yes, goto is one of the things I tend to loathe, especially in this kind of case)
I'm waiting for the white paper entitled "Finding Employment in the Era of Occupational Irrelevancy"
RE: Goto in pascal to Matlab
First declare a boolean variable, say goto100
The code will look something like
CODE
Blow := 1.5E+2;
repeat
B := (Bhigh + Blow)/2.0;
w[1] := Ts; {Surface Temperature}
w[2] := (Ts-T0)/(d1*d2) + L; {Surface Temperature Slope}
y := 0.0;
goto100 := false;
repeat
If w[1] > 1.0 then begin
Blow := B;
goto100 := true;
end
else If w[2] < 0.0 then begin
Bhigh := B;
goto100 := true;
end
else begin
Runge( Equations0, 2, 0.01, y, w );
{writeln(B:25:20,y:10:5);}
end;
until goto100 or Bhigh-Blow < 0.00000005;
until not goto100;
RE: Goto in pascal to Matlab
I realized in reading this that it might sound daunting to you. What I meant was to maybe supply the full Pascal program, along with some idea of what the program does (i.e. calculates the Pygathorean theorem for input). I'm sure you know what it should do (and maybe have the EXE of this somewhere even), since you are wanting to do something with it in Matlab.
Most of us are Pascal-only people but can definitely help you, at least in terms of expressing the algorithm in constructs that Matlab allows. But we would need to be able to fully understand it in order to do that.
I'm waiting for the white paper entitled "Finding Employment in the Era of Occupational Irrelevancy"
RE: Goto in pascal to Matlab
RE: Goto in pascal to Matlab
CODE
CODE
w[2] := (Ts-T0)/(d1*d2) + L; {Surface Temperature Slope}
RE: Goto in pascal to Matlab
CODE
Blow := 1.5E+2;
100:
B := (Bhigh + Blow)/2.0;
w[1] := Ts; {Surface Temperature}
w[2] := (Ts-T0)/(d1*d2) + L; {Surface Temperature Slope}
y := 0.0;
repeat
If w[1] > 1.0 then begin
Blow := B;
goto 100;
end;
If w[2] < 0.0 then begin
Bhigh := B;
goto 100;
end;
Runge( Equations0, 2, 0.01, y, w );
{writeln(B:25:20,y:10:5);}
until Bhigh-Blow < 0.00000005;
CODE
Blow := 1.5E+2;
{* before the loop:}
{* reset values *}
B := (Bhigh + Blow)/2.0;
w[1] := Ts; {Surface Temperature}
w[2] := (Ts-T0)/(d1*d2) + L; {Surface Temperature Slope}
y := 0.0;
{****************}
while Bhigh-Blow >= 0.00000005 begin
if (w[1] > 1.0) or (w[2] < 0.0) then begin
If w[1] > 1.0 then Blow := B; {adjust new interval to <B, Bhigh>}
If w[2] < 0.0 then Bhigh := B; {adjust new to <Blow, B>}
{* reset values *}
B := (Bhigh + Blow)/2.0;
w[1] := Ts; {Surface Temperature}
w[2] := (Ts-T0)/(d1*d2) + L; {Surface Temperature Slope}
y := 0.0;
{****************}
end;
Runge( Equations0, 2, 0.01, y, w );
end {while}