I am trying to call a function from the command window, but I constantly am obstacle by the message
Undefined function 'gDiscrPdfRnd' for
input arguments of type 'double'.
So, I searched this messaged in google. According to this post here, a possible cause for this is that matlab can not find the file. I found this page which tells of how to add the path. So, I typed in the command
addpath('C:\Users\Eli\Documents\MATLAB\final project\help')
and then I typed in
which gDiscrPdfRnd
which gave me the error 'gDiscrPdfRnd' not found. How can I fix this?
EDIT: The output of cd('C:\Users\Eli\Documents\MATLAB\final project\help');dir is
. IdealGasSimulation.zip randpdf
.. gDiscrPdfRnd funct randpdf.zip
IdealGasSimulation gDiscrPdfRnd funct.zip
There is no file gDiscrPdfRnd.m in the folder, put it into the help directory or add the folder where the gDiscrPdfRnd.m is placed.
Related
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?
I'm brand new to MATLAB and am having trouble importing a module called sigTOOL. My code:
>> path('/space/jazz/1/users/gwarner/sigTOOL/program')
>> sigTOOL
returns:
Undefined function 'fileparts' for input arguments of type 'char'.
Error in sigTOOL (line 72)
parentdirectory=fileparts(which('sigTOOL'));
The weirdest part is that I've actually been able to open this successfully before. I used the same code and haven't edited the sigTOOL directory or changed it's path since. Any ideas?
Your usage of path is wiping out MATLAB's default search path.
If you change the first line to
path(path,'/space/jazz/1/users/gwarner/sigTOOL/program')
the path will be added to the bottom of the search stack. You can add the directory to the top of the stack by using addpath:
addpath('/space/jazz/1/users/gwarner/sigTOOL/program')
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.
It may seem like this question has been asked already, but after several days of dealing with this problem and searching for solutions, I am coming up empty. To begin, I am using matlab2012a
So I have the mexa64 file compiled, let's call it foo.mexa64 . My computer can handle 64 bit (matlab >>computer, returns GLNXA64). I have added the folder that foo.mexa64 is in to the path using the pathtool. I did this when I opened matlab, so the changes are there. This is also not in the root/toolbox folder, it is saved in my Documents/MATLAB.../fooDirectory folder.
I can run these mex files in the command line in a different directory and everything works fine. However I cannot call them in a function, I get the "Undefined function 'foo' for input arguments of type 'double'" error.
Using the 'which foo' function returns the path:
home/.../Documents/MATLAB/.../fooDirectory/foo.mexa64
'help foo' returns
foo not found
To check, I created a dummy.m file in the fooDirectory folder. This function can be run in other functions outside of the directory with no issue.
If you need anything else, please let me know, I am completely at a loss!
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