0

I am trying to run an octave script in Cmder. The issue I'm having is holding the figure window after executing the script. Here is the entire script I'm running:

N=10^6;
dt=1;
beta=1.4;
mi=1.3/365;
gamma = 1/7;

I(1)=10;
S(1)=N-I(1);

for n=2:600
    I(n) = I(n-1)+dt*I(n-1)*(beta*(S(n-1)/N)-gamma-mi);
    S(n) = S(n-1)+dt*(mi*N-S(n-1)*(I(n-1)*beta/N+mi));
endfor

x=S/N;
y=I/N;
R=1-x-y;

vreme=1:1:600;
figure 1, plot(vreme,y,"r","linewidth",1.5,
    vreme,R,"g","linewidth",1.5,
    vreme,x,"b","linewidth",1.5);
axis([0 200 0 1])
leg=legend("I","R","S")
set(leg,"fontsize",15);
grid on
hold on

After running the script in octave-gui or octave-cli, the figure stays. Running it in Cmder does not.
Here is an image of the figure showing when opening octave interactive mode: issue

I would like the figure to show calling the script (like in the first command) without going in interactive mode (with --persist lets say), How can I make the figure showing just calling octave C:\Users\Dusan\Desktop\SIR1.m ?

I tried using pause but that doesn't load the figure and if I try to interact with it, it crashes.

Dušan Stokić
  • 84
  • 2
  • 11
  • (apologies for the quasi-passive-aggressive comment above, this is generated automatically by the system when one links to a duplicate question ...) – Tasos Papastylianou Jul 06 '21 at 15:27
  • @TasosPapastylianou Somewhat yes. I've followed the question and some subsequent links. It would seem there is no way of plotting the figure without running the interactive mode. So what I'm trying to attempt seems impossible apart form setting a `pause` for a certain period of time. – Dušan Stokić Jul 06 '21 at 17:04
  • ... did you try `waitfor( gcf )` as mentioned in the duplicate? This really is the canonical way to hold a script open until a figure is closed. Or is that not what you're trying to do? (if your figure is 'blank', try `drawnow` or `refresh` before the waitfor command) – Tasos Papastylianou Jul 07 '21 at 10:35
  • Yes I have. The `waitfor(gcf)` doesn't even show the figure when I run it in cmder. – Dušan Stokić Jul 07 '21 at 10:55
  • as in, the figure comes up blank? or as in the figure window itself doesn't even come up? – Tasos Papastylianou Jul 08 '21 at 11:03
  • I have installed octave v6.2.0 and Cmder v1.3.18.1106 on Windows 10 and can confirm the above code with an added `drawnow; waitfor(gcf)` instruction at the end works as intended. The script was run as follows: `"C:\Program Files\GNU Octave\Octave-6.2.0\mingw64\bin\octave-gui.exe" waitfortest.m`. Are you doing something differently? (PS, in my case `drawnow` was not actually neeeded, but I add it here just in case) – Tasos Papastylianou Jul 08 '21 at 11:37

0 Answers0