Generally, I would like to be able to parse output of Octave commands such as pkg list image. Unfortunately, I cannot assign the output to a string, such as s = pkg list image.
I know that it's not absolutely necessary to be able to do this, because the error message when doint pkg load thispackagedoesnotexist is clear enough, but I'd still like to know whether it's possible, and if yes, how.
You should not need to parse the printed output of Octave functions. Octave functions return values, and it's much simpler and obvious to check those values instead.
In your specific case, you only want to check if a package is installed. So just check if the package appears listed in pkg:
installed = cellfun (#(x) x.name, pkg ("list"),
"UniformOutput", false);
if (! any (strcmp (installed, "foo")))
# Package foo is not installed
endif
or check if its description is empty:
if (isempty (pkg ("describe", "foo"){1}))
# Package foo is not installed
endif
Use system command launching another copy of octave:
[output,text]=system("echo 'pkg list image' |octave -q 2>/dev/null",true);
output is:
output = 0
text = Package Name | Version | Installation directory
----------------+---------+-----------------------
data-smoothing *| 1.3.0 | /usr/share/octave/packages/data-smoothing-1.3.0
dataframe | 0.9.1 | /usr/share/octave/packages/dataframe-0.9.1
general *| 1.3.4 | /usr/share/octave/packages/general-1.3.4
io *| 2.0.2 | /usr/share/octave/packages/io-2.0.2
linear-algebra *| 2.2.0 | /usr/share/octave/packages/linear-algebra-2.2.0
miscellaneous *| 1.2.0 | /usr/share/octave/packages/miscellaneous-1.2.0
nnet *| 0.1.13 | /usr/share/octave/packages/nnet-0.1.13
odepkg *| 0.8.4 | /usr/share/octave/packages/odepkg-0.8.4
optim *| 1.3.0 | /usr/share/octave/packages/optim-1.3.0
optiminterp *| 0.3.4 | /usr/share/octave/packages/optiminterp-0.3.4
parallel *| 2.2.0 | /usr/share/octave/packages/parallel-2.2.0
plot *| 1.1.0 | /usr/share/octave/packages/plot-1.1.0
splines *| 1.2.6 | /usr/share/octave/packages/splines-1.2.6
statistics *| 1.2.3 | /usr/share/octave/packages/statistics-1.2.3
strings *| 1.1.0 | /usr/share/octave/packages/strings-1.1.0
struct *| 1.0.10 | /usr/share/octave/packages/struct-1.0.10
symbolic *| 1.1.0 | /usr/share/octave/packages/symbolic-1.1.0
Also, you can list all packages. From octave documentation:
'list'
Show the list of currently installed packages. For example,
installed_packages = pkg ("list")
returns a cell array containing a structure for each installed
package.
If two output arguments are requested 'pkg' splits the list of
installed packages into those which were installed by the
current user, and those which were installed by the system
administrator.
[user_packages, system_packages] = pkg ("list")
The option "-forge" lists packages available at the
Octave-Forge repository. This requires an internet connection
and the cURL library. For example:
oct_forge_pkgs = pkg ("list", "-forge")
It's difficult to tell what you actually want to do with the output, but it is entirely possible that the pkg function will return information into a useful variable for you if you call it the right way. I recommend you check out the help for pkg function and look at the functional form and the type of things it will return
https://www.gnu.org/software/octave/doc/interpreter/Installing-and-Removing-Packages.html
For example:
[desc, flag] = pkg ("describe", "secs1d", "image")
will return flag which will tell you the installed or loaded state of the package.
Related
I want to build Qt 6 with prebuilt MySQL/OpenSSL libs to try out new features, but I have some issues with configure parameters.
For example, I have such configure parameters:
configure.bat -debug -static -static-runtime -confirm-license -opensource -nomake examples -no-ltcg -sql-mysql -openssl-linked -prefix "C:\Test\6.0.0\msvc2019_64"
When I add the -sql-mysql or -openssl-linked parameters I got the following issue:
CMake Error at qtbase/cmake/QtProcessConfigureArgs.cmake:788 (message):
CMake exited with code 1.
Also, I have tried to use -skip qtwebengine, but cmake returns BUILD_qtwebengine not used by the project. Some of the parameters does not translate into cmake properly. Where I can get full list of cmake parameters to build the Qt 6?
[Updated]
I have translated a few parameters to cmake:
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DQT_BUILD_EXAMPLES=OFF -DINPUT_static_runtime=ON -DFEATURE_ltcg=OFF -DCMAKE_INSTALL_PREFIX="C:\Test\6.0.0\msvc2019_64" -G Ninja C:\QtBuild\qt-everywhere-src-6.0.0
But still can not find any docs how to translate those: -confirm-license -opensource -skip qtwebengine -openssl_linked -sql-mysql
I have previously built MySQL libs by using CMake Option Reference: https://dev.mysql.com/doc/mysql-sourcebuild-excerpt/8.0/en/source-configuration-options.html#cmake-option-reference
Is there any similar reference available for Qt 6? Thank you.
Thanks to lixinwei (https://bugreports.qt.io/browse/QTBUG-89993) the issue is resolved. Now, it successfully finds the OpenSSL and MySQL libs.
Cmake paramaters:
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DQT_BUILD_EXAMPLES=OFF -DINPUT_static_runtime=ON -DFEATURE_ltcg=OFF -DBUILD_qtwebengine=OFF -DOPENSSL_ROOT_DIR="C:\OpenSSL\openssl-1.1.1i\static\x64\debug" -DOPENSSL_USE_STATIC_LIBS=TRUE -DOPENSSL_MSVC_STATIC_RT=TRUE -DINPUT_sql_mysql=ON -DMySQL_INCLUDE_DIRS="C:\MySQL\mysql-5.7.32-winx64\debug\include" -DMySQL_LIBRARIES="C:\MySQL\mysql-5.7.32-winx64\debug\lib\mysqlclientMTd.lib" -DCMAKE_INSTALL_PREFIX="C:\QtStatic\6.0.0\msvc2019_64" -G Ninja C:\QtBuild\qt-everywhere-src-6.0.0
list all qt6 features as cmake flags:
find . -name configure.cmake | xargs cat | grep ^qt_feature | cut -d'"' -f2 | sed 's/-/_/g; s/^.*$/ "-DQT_FEATURE_&=ON"/' | tee all-features.txt
head all-features.txt
"-DQT_FEATURE_qtwebengine_build=ON"
"-DQT_FEATURE_qtwebengine_core_build=ON"
"-DQT_FEATURE_qtwebengine_widgets_build=ON"
"-DQT_FEATURE_qtwebengine_quick_build=ON"
cat all-features.txt | grep some_feature
I just installed Octave a few days ago and think I have been installing packages using the "pkg load name" function but never get a confirmation or anything that looks like the software is trying to download them. I also tried pkg install -forge package_name but that doesn't seem to work. Is there a difference between the two calls?
And; How can I know they are downloading? And where can I find a list of them that are?
The download function and automatic package installation in octave 4.2.1 is broken under windows. Nevertheless the standard packets come with the base installation. Just type
pkg list
in the octave console to display all installed packages. In my case the resulting list starts with these lines
Package Name | Version | Installation directory
---------------------+---------+-----------------------
communications | 1.2.1 | C:\Octave\OCTAVE~1.1\share\octave\packages\communications-1.2.1
control | 3.0.0 | C:\Octave\OCTAVE~1.1\share\octave\packages\control-3.0.0
data-smoothing | 1.3.0 | C:\Octave\OCTAVE~1.1\share\octave\packages\data-smoothing-1.3.0
database | 2.4.2 | C:\Octave\OCTAVE~1.1\share\octave\packages\database-2.4.2
dataframe | 1.1.0 | C:\Octave\OCTAVE~1.1\share\octave\packages\dataframe-1.1.0
...
To get package information programmatically use
[dummy,info]=pkg('list');
info is a cell array of structures containing information about the packages. You can e.g. read the information about name and load state:
>> info{1}.name
ans = signal
>> info{1}.loaded
ans = 0
To get help about the package function enter help pgk on the command line. This help is currently (Octave 5.1) not included in the html documentation. That means doc help does NOT display this help page.
octave windows
I have installed python (2.7.8), sympy (0.7.5) and symbolic package (2.3.0) in Octave (4.0.0). In Octave I did
pkg install symbolic-2.3.0.tar (without errors)
pkg load symbolic (without errors)
And now I am trying to use it:
>> symbols
error: 'symbols' undefined near line 1 column 1
Windows 7, 64-bit. The package seems to be in the list of installed ones:
Package Name | Version | Installation directory
--------------+---------+-----------------------
control *| 3.0.0 | C:\Octave\Octave-4.0.0\share\octave\packages\control-3.0.0
financial *| 0.5.0 | C:\Octave\Octave-4.0.0\share\octave\packages\financial-0.5.0
io *| 2.4.1 | C:\Octave\Octave-4.0.0\share\octave\packages\io-2.4.1
optim *| 1.5.1 | C:\Octave\Octave-4.0.0\share\octave\packages\optim-1.5.1
signal *| 1.3.2 | C:\Octave\Octave-4.0.0\share\octave\packages\signal-1.3.2
splines *| 1.2.9 | C:\Octave\Octave-4.0.0\share\octave\packages\splines-1.2.9
struct *| 1.0.13 | C:\Octave\Octave-4.0.0\share\octave\packages\struct-1.0.13
symbolic *| 2.3.0 | C:\Octave\Octave-4.0.0\share\octave\packages\symbolic-2.3.0
Why is the package not used? Would be grateful for any advice.
There is not "symbols" in current version of symbolic package. You can see example of code in wiki. You can try use syms for testing of loading symbolic package:
>> syms x
Read documentation - Octave-Forge
May be useful link - symbolic-computation-and-octave
I want to compile AUDIT_NULL plugin using Visual Studio Express. I have compiled it on windows with mingw like
$>gcc -Iinclude -fPIC -share d -o plugin_example.dll plugin\audit_null\audit_null.c -DMYSQL_DYNAMIC_PLUGIN
successfully.
But I have no idea where to put option MYSQL_DYNAMIC_PLUGIN in VSE2013. I put it in Properties | Configuration | C++ | Additional Parameters like /DMYSQL_DYNAMIC_PLUGIN= and /DMYSQL_DYNAMIC_PLUGIN and MYSQL_DYNAMIC_PLUGIN= and MYSQL_DYNAMIC_PLUGIN, and to Command Line like /DMYSQL_DYNAMIC_PLUGIN= and in some other places but have no effect. I also tried to put definition just into source code but it didn't help.
Im having a hard time using QTOctave on Xubuntu.
Im trying to display a Bode Diagramm but I constantly get the error message from the Octave Terminal:
**warning: dcgain: unstable system; dimensions: nc=0, nz=2, mm=1, pp=1
error: 'create_set' undefined near line 141 column 16
error: called from:
error: /home/octave/control-1.0.11/__bodquist__.m at line 141, colum
n 14
error: /home/octave/control-1.0.11/bode.m at line 134, column 12
error: /home/M/Regelungstechnik/bodeTest.m at line 7, column 1
>>>**
And it is really not a difficult M file:
tau=1/5
z=1;
n=[tau,1, 0]
G=tf(z,n)
bode(G)
I am running it on my Xubuntu 14.04 Desktop and I have the following packages for Octave installed:
>>> pkg list
Package Name | Version | Installation directory
-------------------+---------+-----------------------
control *| 1.0.11 | /home/octave/control-1.0.11
fpl *| 1.2.0 | /home/octave/fpl-1.2.0
gnuplot *| 1.0.1 | /home/octave/gnuplot-1.0.1
ident *| 1.0.7 | /home/octave/ident-1.0.7
informationtheory *| 0.1.8 | /home/aronheck/octave/informationtheory-0.1.8
integration *| 1.0.7 | /home/octave/integration-1.0.7
missing-functions *| 1.0.2 | /home/octave/missing-functions-1.0.2
odebvp *| 1.0.6 | /home/octave/odebvp-1.0.6
plot *| 1.0.8 | /home/octave/plot-1.0.8
simp *| 1.1.0 | /home/octave/simp-1.1.0
I hope you can help me with my problem.
There can be two things why it's not working:
Do you get the same error when you run just Octave, i.e., without QtOctave? QtOctave was abandoned many years ago it is know to not work very well with newer Octave versions.
Your version of the control package is very very old. It seems that you have version 1.0.11 installed but the latest version is 2.8.0. I checked the ubuntu repositories for 14.04 and they have version 2.6.2.
Running Octave 3.8.2 with control version 2.8.0, your code works fine for me:
octave-cli-3.8.2:1> pkg load control
octave-cli-3.8.2:2> tau=1/5
tau = 0.20000
octave-cli-3.8.2:3> z=1;
octave-cli-3.8.2:4> n=[tau,1, 0]
n =
0.20000 1.00000 0.00000
octave-cli-3.8.2:5> G=tf(z,n)
Transfer function 'G' from input 'u1' to output ...
1
y1: -----------
0.2 s^2 + s
Continuous-time model.
octave-cli-3.8.2:6> bode(G)