Closed VictorGerin closed 3 years ago
HI, can you post a simple sample that reproduces this issue? Thanks
of course first a small video and i will share my code and my data file
` clear all; close all; clc; pkg load signal;
divisor = 40; Fs = 5e6 / divisor; M = dlmread('Teste_rapido_final.csv',';',2,0);
tempo = decimate(M'(1, :)', divisor) ; voltage = decimate(M'(2, :)', divisor) ;
M = 5; voltageFiltrado = filter((1/M)*ones(1,M),[1 zeros(1,M-1)], voltage);
subplot(2, 1, 1); [ax, h1, h2] = plotyy( tempo, voltage, tempo, voltageFiltrado );
set(ax(1),'YLim',[-10 10]) set(ax(2),'YLim',[-10 10])
Nfft = length(tempo); fvec = (-Nfft/2 : Nfft/2 - 1) * Fs / Nfft; fvec = fvec'; Xreal = fftshift( fft(voltageFiltrado, Nfft) );
[a, b] = max( abs (Xreal) );
fvec(b)
subplot(2, 1, 2); plot( fvec, 20*log10(abs(Xreal)) ); pause()
`
I can try to take a look this weekend. Right now I believe this might be related to issue #24 In that issue I suggested to use
while true
pause (1000/60);
end
print("Quitting...");
at the end of the code. That somehow seemed to help.
Another option is setting the "autoTerminate": false,
I can't remember exactly, but that might help. You'll have to press stop manually in that case.
I tested that program on maxOS and it works without crashing with "autoTerminate":
set to either false
or true
. But I guess that might be because of octave using aquaTerm on macOS. Did you test "autoTerminate": false
? Did it help?
yes i did use autoTerminate = false, the plot didn't show.
Hello. I'm experiencing the same on Ubuntu 20 and the only thing that helps is the while true
loop at the end of the program.
My script is very simple:
W = randn(1, 10000)
hist(W)
The plot only shows when the loop is there at the end.
If I set "autoTerminate": false
the plot is not showing up (unless the loop at the end). If I have both "autoTerminate": false
and the loop then on the other hand VSCode seems to disattach from octave-cli because stopping the program does not cause the plot to disappear after debug stops. What i need to do then is killall octave-cli
to make the plot disappear.
So in short, in my case I need both "autoTerminate": false
and the loop at the end.
Don't know if this helps but sharing my findings as I just started using Octave and your plugin, which I find great and very useful.
Actually I've later found that the plots displayed with the while loop didn't have working cursors so I tried launching my octave script by octave command and the plot showed for just a moment and closed by itself. Then I've found this great StackOverflow thread https://stackoverflow.com/questions/52569584/octave-how-to-prevent-plot-window-from-closing-itself and what helped in my case is adding a waitfor
call after the plot. I still get left over with bunch of abandoned octave-cli
processes but it's better now.
Or even better - https://stackoverflow.com/a/62340602 which in an example below works great for me - just press any key to close the window and no octave-cli
processes get left over
t = [0:0.01:0.98]
y1 = sin(pi * 2 * t)
plot(t, y1)
while (waitforbuttonpress ()==0) pause(1) end
Hi Piotr, that's a great find. I like that solution so much I've decided to add it to the plugin readme. This seems to be a problem with octave scripts in general, but that solution also solves issue #24
In practice the "autoTerminate": false
is not needed as the script will never exit due to the while loop.
I've also tested setting a breakpoint on the last line where I added a disp('done...')
.
This will also prevent the script from exiting, so no loop is needed.
You can still view the output as follows:
But checking for the keypress to exit works well for interactive UI elements such as sliders which was the case in issue #24. Additionally, I tested this using a virtualized windows 10 installation, and was able to get the code provided by @VictorGerin to work. I installed octave and set the path as follows:
Then I set "octave": "octave-gui"
as "octave": "octave-cli"
uses fltk and that's a bit wonky on windows.
It seems to work properly. @VictorGerin let me know if this works for you.
If a try show a plot i cant, because i cant use pause or input and if a does the plot crashes