No array2table in Octave - octave

I would like to have function array2table in Octave, same as there is in Matlab.
How to implement it? Any ready code snippet around?

That function does not exist, Octave does not even have the table class which is very much recent in Matlab.
Instead, consider using dataframe which is based on R's data.frame design. Note that you will need to install Octave's dataframe package.

Related

How to find dependend functions in octave

I would like to identify all functions needed to run a specific function in octave. I need this to deploy an application written in Octave.
While Matlab offers some tools to analyse a function on its dependencies, I could not find something similar for Octave.
Trying inmem as recommended in matlab does not produce the expected result:
> inmem
warning: the 'inmem' function is not yet implemented in Octave
Is there any other solution to this problem available?
First, let me point out that from your description, the matlab tool you're after is not inmem, but deprpt.
Secondly, while octave does not have a built-in tool for this, there is a number of ways to do so yourself. I have not tried these personally, so, ymmv.
1) Run your function while using the profiler, then inspect the functions used during the running process. As suggested in the octave archives: https://lists.gnu.org/archive/html/help-octave/2015-10/msg00135.html
2) There are some external tools on github that attempt just this, e.g. :
https://git.osuv.de/m/about
https://github.com/KaeroDot/mDepGen
3) If I had to attack this myself, I would approach the problem as follows:
Parse and tokenise the m-file in question. (possibly also use binary checks like isvarname to further filter useless tokens before moving to the next step.)
For each token x, wrap a "help(x)" call to a try / catch block
Inspect the error, this will be one of:
"Invalid input" (i.e. token was not a function)
"Not found" (i.e. not a valid identifier etc)
"Not documented" (function exists but has no help string)
No error, in which case you stumbled upon a valid function call within the file
To further check if these are builtin functions or part of a loaded package, you could further parse the first line of the "help" output, which typically tells you where this function came from.
If the context for this is that you're trying to check if a matlab script will work on octave, one complication will be that typically packages that will be required on octave are not present in matlab code. Then again, if this is your goal, you should probably be using deprpt from matlab directly instead.
Good luck.
PS. I might add that the above is for creating a general tool etc. In terms of identifying dependencies in your own code, good software engineering practices go a long way towards providing maintenable code and easily resolving dependency problems for your users. E.g: -- clearly identifying required packages (which, unlike matlab, octave does anyway by requiring such packages to be visibly loaded in code) -- similarly, for custom dependencies, consider wrapping and providing these as packages / namespaces, rather than scattered files -- if packaging dependencies isn't possible, you can create tests / checks in your file that throw errors if necessary files are missing, or at least mention such dependencies in comments in the file itself, etc.
According to Octave Compatibility FAQ here,
Q. inmem
A. who -functions
You can use who -function. (Note: I have not tried yet.)

Is igraph R package more perfect than python-igraph?

I try to use igraph package transferring from R to python. But I have one question. For instance, I want to use the graph.bfs function. In R, this function has many parameters. (http://www.inside-r.org/packages/cran/igraph/docs/graph.bfs)
But in python-igraph, I only find the function bfs. (http://igraph.org/python/doc/igraph.GraphBase-class.html#bfs)
Did I miss the similar function in python-igraph or is igraph R package more perfect than python-igraph?
While they are based on the same C library, the Python and R wrappers are somewhat different, so expect to have some differences. I would not say either of them is better or worse, they are just slightly different.
If there is a feature that is implemented in one language, but not in the other, then you can open an issue at the igraph issue tracker at https://github.com/igraph/igraph/issues and request it.

How can I use ord2 function

I'm using Octave right now, but earlier I had used MatLab. In MatLab there is a function ord2 and according to this document (http://www.obihiro.ac.jp/~suzukim/masuda/octave/html3/octave_159.html/) it should also exist in Octave. Could anyone help me with this issue, since I'm new in Octave. How can I import or in other way use 'ord2' function (second-ordered system).
The documentation you mention is for Octave 3.0 which is a very very old version. All of Control functions, together with Finance and Quaternion, were removed from core Octave with release 3.2. If you see the news for Octave 3.2 (if you have a very recent version, this may be in one of the old news file:
** The Control, Finance and Quaternion functions have been removed.
These functions are now available as separate packages from
http://octave.sourceforge.net/packages.html
and can be reinstalled using the Octave package manager (see
the pkg function).
As it is mentioned, you can download the packages from Octave Forge website but depending on your operating system, you may be better off use your package manager.
Finally, the ord2 function does not actually exist in the control package and I'm even unsure that the version you are referring to in Octave 3.0 was even Matlab compatible. However, you can still see its source online right before it was removed.

Is Octave compatible with the CobraToolbox?

I need to use the CobraToolbox for a course and I am wondering if it is compatible with Octave.
Even googling for this doesn't return much results..
Thanks in advance
Unless someone has published their results, you can't know without trying it. However, there is a very high likelihood that it will work on Octave, here's what Jordi has to say on this issue answering this question.
I am new to Octave and was wondering if it is possible to use matlab
toolboxes in Octave?
It depends on what you mean by "Matlab toolbox". If you mean the code
that came with Matlab, it's probably a license violation to use it
with Octave, assuming you can compile it for Octave when it's
necessary to compile.
If you mean free code out there you found on the internet that was
written for Matlab, it is likely it will work on Octave. Just try it.
If you need to compile mex files, the "mkoctfile --mex" command may be
of use.
If you want to have a rough equivalent of the Matlab toolboxes in
Octave, try the Octave-Forge packages:
My personal experience is that Octave has become extremely good at accepting Matlab code. I would hazard a guess that any time you spend setting up Octave and this toolbox will be worth it. Even the MEX files appear to have a portability mechanism. Unless they are using some very specific features like addpref for toolbox persistent data, it will slide right into Octave. Even if they are using the prefs, it could be modified to live in Octave.

Haskell - importing functions from prelude

I have kind of a newbie question. I want to use some functions from prelude, but I'm getting same error all the time.
For example:
Undefined variable "diff"
Some other functions are working, some not. I guess I have to import something, Google didn't help me... I'm using WinHugs.
Here are two sites you should bookmark, because they'll help you find functions you need -- and find out what you need to import.
http://haskell.org/hoogle/
http://holumbus.fh-wedel.de/hayoo/hayoo.html
Searching both those sites, I don't see anything that looks like the function you want. Some possibilities that occur to me are:
You're learning from a book that has examples of things you'd type at the Linux command line. "diff" is a common Linux command for comparing two files. I believe the windows equivalent is comp.
You're using some sample code that you got somewhere, but you didn't import everything you needed. If you can find the file that contains the "diff" function, import that.
You've written a function called "diff", and put it in another file. In the file where you want to use "diff", you need to import the module that contains it.
Prelude is typically imported implicitly. Are you sure that is really your problem? Undefined variable "diff" is a bit vague, since I don't know of a diff function imported with Prelude. Can you elaborate?