Note that there are some explanatory texts on larger screens.

plurals
  1. POtranslating loop from Fortran to MATLAB
    primarykey
    data
    text
    <p>I'm currently translating code from Fortran to MATLAB manually, and I am unsure of how to translate part of it. (The entire code actually is a 2,000 line subroutine.) The code is below.</p> <pre><code>C Has series crossed neckline? 120 neckext=x(trough(peaknum-1))+ * dydx*real((t-trough(peaknum-1))) if(x(t).lt.neckext) goto 130 C NO. Here if series has not crossed neckline, nor new trough found C Check to see if new trough has been found. t=t+1 if(t.ge.lastobs) goto 900 if(x(t).lt.min) then min=x(t) mindate=t end if troughid=min*(1.0+cutoff) if(x(t).ge.troughid) goto 150 goto 120 C YES. Here if series crossed neckline before new trough found 130 dblcount=0 if(poscount.ge.1) then DO 132 i=1,poscount if((enterdt(i)-2.le.t).and.(t.le.enterdt(i)+2)) then dblcount=dblcount+1 end if 132 continue if(dblcount.ge.1) then C write(30,2583) t,Cutnum 2583 format('DoubleCounting episode occurred at ',I5, * ' with Cutoff = ',F3.1) goto 150 end if end if </code></pre> <p>My problem is with this part of the code:</p> <pre><code> if(x(t).ge.troughid) goto 150 goto 120 </code></pre> <p>When I was translating this part in MATLAB, I was writing something like:</p> <pre><code>if x(t,:)&gt;=troughid t=marker; minimum=x(t,:); end </code></pre> <p>But I don't know what to do with the label 120. When I translate it, do I write that part again? Because from what I understand, when I go back to 120, the code will be running again. Thanks!</p> <p>EDIT: As a response to Chris's question on what labels 150 and 900 do, I'll post them here.</p> <pre><code>150 t=marker min=x(t) </code></pre> <p>And this is for the label 900.</p> <pre><code>C Last observation found. This iteration finished. 900 continue </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload