Cannot create plots in Jupyter using Octave - jupyter

I'm attempting to get Octave working in Jupyter and while I can execute basic math, I cannot get plots to work. Regardless of what type of graphics library I try to use, I get an error similar to this:
error: feval: function '__init_gnuplot__' not found
error: called from
graphics_toolkit at line 98 column 5
Here's the code that faileds:
register_graphics_toolkit('gnuplot');
available_graphics_toolkits()
graphics_toolkit("gnuplot");
I did some investigation and my best guess is that it looks like it's looking for a file called __init_gnuplot__.cc, based on the fact I found a file with a similar name but ends with '-tst'. However, that file doesn't exist and grepping the entire file structure under the octave directory doesn't find any instances of the function in the error.
Has Anaconda removed that functionality? Does anyone know where that '__init_gnuplot__' function is supposed to be located? Or, better yet, does anyone know how to resolve this?

Related

Cannot create .xlsx file in Octave 3.8.2

I have just switched from Matlab to Octave 3.8.2 and spending a lot of hours to rewrite my programs.
The issue I am currently having is related to io pkg's xlswrite function.
In the code I have implemented, my Matlab code would search a directory for an .xlsx file with a given name. If there was such a file, it would change the filename to filename_v2 and write data in it , else it would create it first and then write data in it.
However, Octave doesn't seem to work this way.
Actually, whenever I am trying to create a file using xlswrite function I get the following error:
error: xlsopen.m: file filename.xlsx not found
Any idea how I could go round this problem?
Thank you very much in advance.
Kostas
EDIT: I am using Windows 7 and the exact code is:
if exist('Data Logger.xlsx','file')==0
name='Data Logger.xlsx';
else
found=1;
v=1;
while found==1
v=v+1;
name_cand=strcat('Data Logger_v',num2str(v),'.xlsx');
if exist(name_cand,'file')==0
found=0;
end
end
name=name_cand;
end
xlswrite(name,Header)
Solved: Its seems that Octave does not accept spaces in filenames.
Changed Data Logger.xlsx to Data_Logger.xlsx and everything worked perfectly
Thank you all for your willingness to help.
Cheers, Kostas

MATLAB IDE: F1-key and doc function displays help for the wrong function

I've been working for some time on a MATLAB function to retrieve file names. The function is called getFileName. My problem is that when I try to display help for this function by pressing the F1 key while cursor is on the function name, I instead, get the help for the built in function matlab.io.hdf4.sd.getFilename. I get the same if I write doc getFileName in my command window. Only if I type helpwin getFileName do I get the correct documentation displayed!
This doesn't make sense to me since MATLAB is case sensitive and thereby getFileName is different from getFilename. Furthermore, when I type which getFileName (or for some strange reason, if I type which getFilename), I get the path to my function and not to the built-in function matlab.io.hdf4.sd.getFilename.
So my question is: is it possible to make sure that the function you get documentation for (by pressing the F1 key) is the same function that you run if you type the name of that function?
Matlab isn't actually case sensitive for the help files. In the terminal you can type
doc PLOT
and it will still pop up the documentation for the proper plot function.
I don't know where these files are stored on PC, as I use a Mac, but in the Matlab directory if you search for an uncommon file name (like plotyy) you will see the source file, but you'll also find an html file that doc uses. If you write an html file for the new file it should bring up the right info for the documentation center.
Matlab used to just copy the commented text at the beginning of the file into the documentation center in older versions of matlab, but now it uses html files stored on your drive. I don't know if this will definitely fix your problem as I haven't written an html file for an "almost overloaded" function.
Also, about the weird 'which' thing, I'm pretty sure Matlab first searches the first entry on your path list for a close match, and the current directory is on the top of the list. If you type 'path' into the console it will output all the search paths, and the top ones are searched first.
I apologize for masquerading as if this is an 'Answer' but I don't have enough reputation points to add this as a comment.

Error in calling ImageMagick from Matlab

I have installed ImageMagick in my system (windows), and its commands are there in system PATH. Its working absolutely fine through Command line
I want to call the "convert" function of ImageMagick from Matlab using system command.
'C:\Users\Vivek' is the Path to image. I have to test working of ImageMagick through Matlab, as i need it in further processing (Making input suitable to Tesseract OCR)
cmd= ['convert ' 'C:\Users\Vivek\208.jpg ' 'C:\Users\Vivek\208.png']
system(cmd);
It says Invalid Parameter - C:\Users\Vivek\208.png, I tried some other ways. But, all the time the problem is with the second parameters.
Need Help
Thanks
Windows comes with its own convert program, and it looks like you're calling that one because it's first on the path in this context. It's described here on ImageMagick's site: http://www.imagemagick.org/Usage/windows/#convert_issue
I do not have ImageMagick installed, and I get the same error message when I try calling convert. That's consistent with your code getting the wrong convert program.
C:\Users\janke>convert C:\Users\Vivek\286.jpg C:\Users\Vivek\208.png
Invalid Parameter - C:\Users\Vivek\208.png
Specify the full path to ImageMagick's convert program and it should work for you.
The solution mentioned in the last post is the standard way to solve the issue, but the simplest way to do this is to just rename the ImageMagick's convert.exe file to something else, like convert1.exe, and use this filename in your scripts.

mat2gray function does not work when called from Perl

I have a script in perl that generates a .m file based on a series of parameters and then runs an octave algorithm through ticks like:
`octave my_script`;
And then I capture the results in a separate file. The problem is that even having installed the image package succesfuly mat2gray function is not working.
If I open manually octave like a separate console to be used manually, and call my script it does work perfectly. The issue appears only when calling the octave.exe from Perl. It shows:
error: `mat2gray' undefined near line 21 column 6
Which looks like the typical error you get when you don't have the image package (and I do have it installed and I'm able to usethe function on octave console directly). I already tried to iclude a line on my script at the very top to rebuild the package everytime my script runs, like so:
pkg rebuild -auto image;
But that didn't fix it. Anyone has seen this kind of odd behavior?
I'm using Octave 3.2.4, since I need that version due to some compatibility issues with other pieces of software that we need. And some plotting capabilities when called from perl don't work all that well. Just in case you were wondering.
For future reference, I replied to the question here.

How to make matlab see functions defined in .m files?

I'm a total newbie to MATLAB but I have to write some code in it. I've had problems with making MATLAB see functions I've defined in external .m files. This is what I've done: I've created a file named, say, foo.m in my home dir with the following contents:
function [y] = foo(x)
% description
y = x + 1
When I run matlab (my home dir is matlab's workdir) it does not see foo function - it replies with standard ??? Undefined function or variable 'foo' message. BUT help foo or which foo return correct data printing help text and pointing on foo.m file respectively.
I must be missing something but I have no idea what it is. This is getting very annoying.
Oh, after several trial and error attempts I've managed to call that function. Unfortunately I can't remember the sequence of steps I've performed. Moreover after restarting matlab it returns to its usual 'Undefined function or variable' response.
I have 7.11.0.584 matlab running on linux.
MATLAB needs to be told which directories to search over to access those m-files. Clearly it cannot be left to search over your entire disk drives. The MATLAB search path is a list of directories that will be searched in specific order to find your functions.
help addpath
help pathtool
You should never put those files anywhere in the official MATLAB toolbox directories. Choose an entirely separate directory.
Finally, be careful not to name your own functions to match the names of existing MATLAB functions. Otherwise, your very next question here will be why your code does not work properly. This is a common cause of strange and confusing bugs.
It seems you're having some trouble with addpath. Try opening the file in the matlab editor and adding a break point in the file. If the file is not on Matlab's path, matlab should ask if you want to change directory or add the file to the path, choose add to the path.
If this doesn't work, try changing the current working directory (displayed in the main window) to the same location as the m file and calling the function. If this doesn't work you're either getting the name wrong ar there's possibly something wrong with your installation.
Occasionally matlab has problems if it does not have write permission to the directory the file's in, so check that too, i.e. make sure admin rights aren't required for the directory or m file.
Oh, and try:
clear functions
to reload all functions into memory.
The function needs to be in MATLAB's path. Use pathtool to tell MATLAB where to find your function. Note that if you name a function the same name as an existing function, MATLAB will use whichever function it finds first according to the order that the paths are listed as you see them in pathtool.
Although coming late but I hope it will help someone.
If in the folder where the function you are calling is residing, there is any other function with the same name as one of the functions from MATLAB toolboxes, then Matlab will not recognize its license and therefore will disable the whole folder from execution, no matter it is properly added to the path. The help will display though.
In order to check it, type:
which name_of_func.m
and you will get the path with "%Has no license available" message.
If it is your own function, you should not get this message but only the path.
Therefore, find the function in this folder which has the same name as a MATLAB toolbox functions, and rename it. I will solve the problem :).
Best Regards
Wajahat