calling a matlab function with scalar type
Afficher commentaires plus anciens
I am collecting data from a Simulink model into an array so I can manipulate it using a custom function in Matlab. The data is an array of dimensions 1601 x 1, single precision data. Now, I want to operate on one element of this data with my own function which is written in C and converted into a MEX function.
The function works fine with data entered like this:
x = 0.2345
myFunc(x)
...yet when I do this:
x = arr(100)
myFunc(x)
I get the error:
Error using myFunc
Input multiplier must be a scalar.
...however this
isscalar(x)
...yields this...
ans =
logical
1
...so is 'x' a scalar or not?
If not, how can I make it a scalar so I can call it with my function? Thanks.
6 commentaires
Geoff Hayes
le 30 Jan 2017
Richard - can you attach your myFunc so that we can see what it is doing? Perhaps the error message, Input multiplier must be a scalar. is incorrectly being written to the console and it should be some other error message instead.
Also, what is x equal to once you assign it as
x = arr(100)
Honglei Chen
le 30 Jan 2017
It would be helpful if you could share what's the result when you do
whos arr x
Richard Poley
le 30 Jan 2017
Richard Poley
le 30 Jan 2017
Geoff Hayes
le 30 Jan 2017
Richard - can you attach the C code instead? I would like to see that as opposed to the compiled Mex function. (Should be able to just attach the code rather than a zip file, even if you have to rename it with a txt extension.)
Richard Poley
le 30 Jan 2017
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!