Quantile function causing error in MATLAB - matlab

I am using quantile function in the simplest form:
x = [1.2,3,4,5];
y = quantile(x,0.5);
But I get the error:
Undefined function 'quantile' for input arguments of type 'double'.
I was not having this error in MATLAB R2009a but get this error in R2012a.
What could be the reason?

Please run:
license('test', 'Statistics_Toolbox')
In case this returns a 0 then you do not have an active license of the statistics toolbox.
However if you want to use it as in your example the following code would do:
y = median(x);

quantile is part of the statistics toolbox. If you do not have access to that in your new installation, you will not be able to use the function.
To check which toolboxes you have installed, type ver at the command prompt.

Related

Why is fgoalattain built-in function not working in MATLAB?

I'm trying to invoke an fgoalattain function (computing a function minimum with a goal-attainment algorithm) in MATLAB. According to documentation, it should look like this:
[X,FVAL,ATTAINFACTOR] = FGOALATTAIN(#objf_1,x0,goal,weight)
where #objf_1 is a function handle for a function defined in objf_1 m-file and the rest are some arguments I set on my own. They are not important in any case, because evidently MATLAB has a problem with that function, as it throws:
>> rospar_4
Undefined function 'fgoalattain' for input arguments of type 'function_handle'.
Error in rospar_4 (line 29)
[X,FVAL,ATTAINFACTOR] = fgoalattain(#objf_1,x0,goal,weight)
However, I already know that the function works fine on another MATLAB version - R2011b (the one I'm using is R2012b), but with first argument as char instead:
[X,FVAL,ATTAINFACTOR] = fgoalattain('objf_1',x0,goal,weight)
If I try to invoke it like this in mine though, the error is almost the same:
>> rospar_4
Undefined function 'fgoalattain' for input arguments of type 'char'.
Error in rospar_4 (line 29)
[X,FVAL,ATTAINFACTOR] = fgoalattain('objf_1',x0,goal,weight)
Any idea how am I getting this?
It is not a built-in function. You need to install the Optimization toolbox.

Matlab Error: Undefined function 'knnclassify' for input arguments of type 'double'

I am trying to do knnclassify on test_data(10000X784), train_data(50000X784), train_label(50000X1) and k = 1
And I am calling this function as follows:
label = knnclassify(test_data,train_data,train_label,k);
Background:
Where train_label is numeric equivalent digit of the data given in train_data. I want to classify my test_data. The data in both the train and test are in random order, but the train_label totally corresponds with the data in the train_data.
In my friend's workstation it works fine, but in my laptop it gives this error:
Undefined function 'knnclassify' for input arguments of type 'double'.
What could be the reason for the issue and how to solve it? Do I need to install any package? If yes how?
This error means that the function cannot be found in matlab, so you might missing the required toolbox. Just as #schorsch said you need to install the Bioinformatics toolbox.
A way to find out if the function is available in Matlab is typing which knnclassify. The output will be the route where the function resides or 'knnclassify' not found. otherwise.

Matlab table function

I have tried running the example as shown in the documentation of MuPAD table:
T := table(a = 13, c = 47)
Doing so gives me the following error:
Undefined function 'T' for input arguments of type 'char'.
I have no idea what is going on. Does anybody know why it isn't working and how I can create a table using this function?
If you look at the top of the page, you are reading about functions contained in the "Symbolic Math Toolbox." I believe you need to pay for that license to use functions from the toolbox.
From Matlab's help for that error you either:
Made a typographical error ...
Changed directories so that a function is no longer on the search path...
Used the wrong case for a function or variable name ...
Are trying to use a function for which you are not licensed.
I got the same error as you, and I also do not have that Toolbox, so perhaps its the last reason.
Is it time to switch to Python?
This happens when you try to call a muPAD function from the MATLAB command line. Whenever you see :=, that's a clue that you're dealing with muPAD. You cannot use muPAD syntax directly in MATLAB (feval or evalin and symengine can be used in some cases to call muPAD functions and return a symbolic expression).
To use table in muPAD:
Call mupad at the command line to open up a muPAD notebook, then call your sample line. You do not need the latest MATLAB version, although I'm not sure exactly when it was brought in (works fine for me on 2011b with Symbolic toolbox).
To use table in MATLAB:
The muPAD table function should not be confused with the MATLAB table function/datatype, which is relatively new. The equivalent in MATLAB of that muPAD code would be something along the lines of (untested):
T = table([13;47],'RowNames',{'a';'c'});

adftest function error in lagmatrix

Using the adftest function in MATLAB's econometrics toolbox, I'm receiving the following error:
>> [h1,pVal1] = adftest(y1,'model','ARD')
Error using lagmatrix (line 25)
lagmatrix: wrong # of input arguments
Error in adftest>runReg (line 705)
yLags = lagmatrix(y,0:(testLags+1));
Error in adftest (line 417)
testReg = runReg(i,y,testT,testLags,testModel,needRegOut);
y1 is a <41x1> vector of doubles.
Has anyone received this error or have any thoughts on what the issue is? I am using this code right out of the box so I'm not sure what is going on. I'd post to MATLAB's site, but it is down for maintenance.
This is either a bug in Matlab, in which case you should submit it on the Matlab support site. Before you do that, you should check that you don't have a function lagmatrix on your path that shadows the built-in function. Type
which lagmatrix
on the command line. If the path does not point to your Matlab installation, you should move lagmatrix off the Matlab search path.
Also note that y1 should not contain all NaN, or be otherwise degenerate, so you may want to check the function using the sample data as suggested in the help to be sure it's a bug and not just your data.
I had the same problem with this function. In my case, the problem was the function lagmatrix (older version) in my MATLAB path and the adftest function was the newest version. The soluction was delete the older version of lagmatrix.

bi2de error in MatLab

In MatLab, "> help bi2de" provides the following example:
B = [0 0 1 1; 1 0 1 0];
D = bi2de(B)
But when I try this on my own, I get the following error:
??? Undefined function or method 'bi2de' for input arguments of type 'double'.
Is there something wrong with this function in MatLab?
I am pretty sure that the reason why this problem happened is because of the license of the toolbox, Communications system toolbook, in which this function belongs in. Write which bi2de and see what will be the result. If it returns path of the function and the comment Has no license available, then the problem is related to the license. That means, license of the toolbox is not set correctly. Mostly it happens if the toolbox is added later, i.e., after installation of the original matlab. Please check and solve the license issue, then it will work fine.
bi2de is a function in the Communications toolbox. You need to have that toolbox to use it. If you do have that toolbox, then the problem is that your B matrix is being treated as double instead of binary (I don't have the toolbox so I can't test this).
Consider using bin2dec, which turns a string representation ('1011001', eg) into a decimal number. This function is not part of a toolbox; it's available as part of the basic MATLAB package.