Does Octave have the xline function for drawing vertical lines? - octave

Does GNU Octave have the xline function for drawing a vertical line with constant x values?
I searched around, but all results seem to be for matlab, not octave (as of Octave 5.2 in Ubuntu 20.04 LTS). Do I need to install an additional package for this?

No, but creating your own is "trivial".
xline = #(xval, varargin) line([xval xval], ylim, varargin{:});
This should work well for adding vertical lines in an existing figure (i.e. such that the ylim function will result in the size of the window automatically).

Related

Is there a way to introduce a delay in a system analyzed with the octave control package

I'm trying to analyze the system
20*e(0.9*s)
-------------
(s+10)
using GNU octave and the control package, but I cannot find the way to introduce the exponential (the exp octave function does not work).
The code I tried to write is
pkg load control
s = tf('s')
g = 20*exp(0.9*s)/(s+10)
but the following error is shown: error: exp: not defined for class
I tried searching the web a bit, without success.
Thanks in advance

Enlarge markers on Octave rlocus

Is it possible to make the markers (zeros and poles) from rlocus on Octave?
I've found the following answer, but the file that is supposed to be modified does not seem to be used anymore, or at least I wasn't able to find it with locate on Linux.
https://electronics.stackexchange.com/questions/372728/octave-rlocus-format-ploles-and-zero
This is the code I'm using to generate the plot.
pkg load control;
s = tf ('s');
GH = (s + 1)/(s*(s + 2))
rlocus (GH);
This is the plot generated by the code:
But the poles and zeros are almost invisible on the standard plot.
Thanks in advance for any responses.
From within octave, type
which rlocus
on the terminal.
This will tell you the location of the file in your current octave / control-package installation.
You can then proceed and edit the file as per the instructions of the previous post.

"pause" is not pausing the execution of script in Octave 5.1.0 in Windows 10

pause should stop the execution until something happens. But in my case where i have OCTAVE 5.1.0 on OS WINDOWS 10 is not doing its work properly. It does ignore all pause statements in script and execute the whole file.
I am running this program in my installed octave application in command window with GUI.
What may be the problem?
I have tried pause with function brackets
pause();and without function brackets pause; but still problem remains same.
%do something
plotData(X, y);
fprintf('Press enter to continue.');
pause;
%do something
plotData(X, y);
I except that script will first plot data and will stop execution till key is pressed to enable me to analyze data then after key press it would plot another plot with processed data.
But it just plot both plots in fast manner that i could not see it.
There are few bugs related to pause that have been introduced since version 5.1 and seem that recently have been fixed. It will be available in the next version. You can try alternative functions like kbhit or switch to a previous version.

Octave: View a figure

I have the following code saved as script.
% demonstration of hold
clf;
t = linspace (0, 2*pi, 100);
plot (t, sin (t));
hold on;
plot (t, cos (t));
title ({"hold on", "2 plots shown on same graph"});
hold off;
When I execute the script within Octave, Octave's viewer shows the figure.
However, when I execute the script from the command line (Ubuntu) the viewer opens and closes alone very quickly without showing any figure.
I don't know if this issue has to do with Octave or Ubuntu. I apologize if the question is very naive.
When running and Octave script from the command line, Octave is launched to execute it, and when the script ends, Octave terminates too. This is why you see the figure windows created and immediately destroyed. There no longer is a program running to show these figure windows.
If you add a pause statement at the end of your script, Octave will wait at that statement until you press a key, then continue. So after you press the key, the script ends and Octave terminates. But while it is waiting, the figure windows will be visible.
You can use waitfor to prevent Octave from termination until the figure is closed. First you should get graphic handle of the figure. Some functions including clf , plot ,... can return a graphic handle. Then use waitfor with the handle as its argument.
h = plot(1:10);
waitfor(h);
or
h = clf;
plot(1:10);
waitfor(h);

Octave: Get Date Time Picker

I am trying to tranlate Matlab code in Octave. I am looking for Date Timer picker. I am affraid that there is no such utility in Octave. If so, is there any alternate for this Matlab command in Octave.
uicalendar();
Using Octave: error: 'uigetdate' undefined
Do I need some package etc. Any solution?
The function uigetdate does not exist in Octave core. It also does not exist in Matlab so I don't know where you got it from.
However, there is a function to pick a date from a calendar in the Octave zenity package. The zenity package is unmaintained but seems to still works fine.
octave> pkg load zenity
octave> date = zenity_calendar ()
date = 13-Nov-2017
Which will look like this on my system (Gnome 3):
The Octave zenity package is a wrapper to the zenity program so you will need to have it installed in your system.