How to define input types in Matlab Coder for a function that has a varying number of input?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a function let's say sq_dist(). This function can be called like this sq_dist(a,b) or sq_dist(a). This function includes slow operations and thus I am trying to make a Mex version of it hoping that it will run faster. I am using the Matlab Coder GUI to do so. In order to define input types (in the define input screen) i use a function that calls sq_dist(a,b) and sq_dist(a) to automatically determine input. This gives me an error: Error determining type for input sq_dist:b. Index exceeds matrix dimensions. Here is my function:
n = 50;
dim = 50;
a = rand(n, dim);
b = rand(n, dim);
u = sq_dist(a, b);
v = sq_dist(a);
So, since sq_dist can be called in different ways I am not sure how to define its input in the Coder.
If i manually set the input to double :inf x :inf for a and b the mex file is compiled but i get a runtime error: Function 'sq_dist' called with wrong number of arguments: expected 2, received 1.
0 commentaires
Réponses (1)
srj4anoop
le 11 Mai 2016
Modifié(e) : srj4anoop
le 11 Mai 2016
Hi Alex,
You can make use of 'varargin' keyword to pass variable number of arguments to a function. For more info on varargin refer the following link
Also, refer to the following link on the rules to follow while using 'varargin' for code generation
Voir également
Catégories
En savoir plus sur MATLAB Coder dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!