Error in MATLAB.Undefined function 'det' for input arguments of type 'embedded.fi' - matlab

I have already seen the link Error using fzero in Matlab: Undefined function or method 'det' for input arguments of type 'function_handle'
But I am unable to solye my problem with this link.I am working with fi object in MATLAB. I have one matrix T_1 (2 cross 2) which is conevrted into the fi(T_1,1,32,26,fimath), i.e 32 signed binary number and 26 is the positon of binary point. Now when I try to excute the follwing code
T = mat_G/(mat_sqrt_D)
T_1=fi(T./mat_E,1,32,26,fimath);
multiplier=1/(2*sqrt(det(var_oldS))*abs(det(T_1)));
follwing error appears
Undefined function 'det' for input arguments of type 'embedded.fi'.
So can anyone tell me how can i fix it.
P.S variable var_oldS, mat_G,mat_E, mat_qrt_D has the same fi object properties i.e fi(variable_name,1,32,26,fimath)

If you check the documentation for det, it says that the input must be single or double. Fixed point is probably not supported. As your matrix is of fixed size 4, it's simple to replace the function:
det2=#(M)M(1)*M(4)-M(2)*M(3)
Then use det2 instead of det.

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: Undefined function 'libsvmwrite' for input arguments of type 'char'

I'm trying to convert a CSV file to LIBSVM/SVMlight format. I found the following code to do it:
SPECTF = csvread('SPECTF.train'); % read a csv file
labels = SPECTF(:, 1); % labels from the 1st column
features = SPECTF(:, 2:end);
features_sparse = sparse(features); % features must be in a sparse matrix
libsvmwrite('SPECTFlibsvm.train', labels, features_sparse);
I used it on Octave on a specific file, and it worked properly.
However, when trying it on MATLAB, I received the error:
Undefined function 'libsvmwrite' for input arguments of type 'char'.
Neither "labels" nor "features_sparse" are chars... (they are doubles). Where is my error? Thanks!
The first argument for libsvmwrite is of type char ( the filename 'SPECTFlibsvm.train'). I think the problem is on the error message given by Matlab. The error message says that the function doesn't exist for input of type char, but most likely it should be that it doesn't exist at all (the message could maybe make sense if Matlab was designed as an OPP language).
Anyway, you simply don't have the libsvmwrite function in your path, or you somehow messed up the installation of the libsvm interface.
Probably you loaded only the source code, which is written in c. You need to compile it. Go to the matlab directory of libsvm and read the instructions.

??? Input argument "x" is undefined

I enter:
EDU>> %using the temporary variable levels
EDU>> levels=range/quantise_range;
levels=round(levels);
quantisation_bits=log2(levels)
NB. There is no x variable anywhere
My error is:
??? Input argument "x" is undefined.
Error in ==> range at 18
y = max(x) - min(x);
EDU>> %combining above process into one statement
quantisation_bits=log2(round(range/quantise_range));
??? Input argument "x" is undefined.
Error in ==> range at 18
y = max(x) - min(x);
Would someone care to explain thie issue? I am beginner into programming and I really don't understand how to read the error hint.
Thanks.
Additionally, in what may be due to whatever the same principle misunderstanding on my part is, I am finding trouble here with this code, with error also included:
%Trying to create my own function, I’m pressing shift+enter at the end of lines for neatness:
EDU>> function what_am_i()
disp 'I am a function'
??? function what_am_i()
|
Error: Function definitions are not
permitted in this context.
EDU>>
function what_am_i()
disp' I am a function'
??? function what_am_i()
|
Error: Function definitions are not
permitted in this context.
EDU>> end
??? end
|
Error: Illegal use of reserved keyword
"end".
You may be confusing the "Command Window" with the "Editor".
In the "Command Window" you can enter some lines of code, but can't create functions. It acts more like a calculator.
If you create and save files, then you open them in the "Editor" and that's when Matlab begins behaving more like a programming language. It saves .m files that can have functions or algorithms written in them.
Matlab has lots of help available. I recommend visiting their website and searching around a bit. (or just google "intro to matlab")
In addition to #user1860611's answer regarding function definitions in the command window, the other problem you have has to do with range, which is a built-in function. It appears you are trying to use range it as a variable name, but didn't actually initialize it to a value, so it is still a function.
In the line here:
levels=range/quantise_range;
you are essentially calling the range function, but without passing it an argument.
Error in ==> range at 18
y = max(x) - min(x);
The error message is telling you that a function called range has generated an error. It doesn't matter that you don't have a variable named x, because the function has one internally.

which format can I give to imstack2vectors Matlab function?

So I have imported RGB photo into my Matlab workspace. It says it has value: <200x200x3 uint8>. Meaning it has class uint8. And its name is: prettyPic. So when I try to do the following:
% Convert prettyPic to vector format using function imstack2vectors.
[prettyPic, L] = imstack2vectors(prettyPic);
I get the following error:
??? Undefined function or method 'imstack2vectors' for input
arguments of type 'uint8'.
I was searching google all around reading the Matlab help and even trying to give 'imstack2vectors' different types of variables only to find that none works.
So the question is what type of picture should I feed the 'imstack2vectors' with. And how can I convert the picture that I have to that format/class.
I am a begginer in Matlab so any help would be greatly appreciated!
??? Undefined function or method 'imstack2vectors' for input arguments of type 'uint8'.
Means that most likely, the function imstack2vectors does not exist on your Matlab path (i.e Matlab cannot find a function of this name).
Type which imstack2vectors to see whether Matlab can find it on the path. If it returns nothing, but you know where the function is on your hard drive, you can change directories in Matlab to where the function is located, and then run your command again.
In general, you may want to learn about adding functions to the Matlab path.