calling a matlab function with scalar type
Show older comments
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 Comments
Geoff Hayes
on 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
on 30 Jan 2017
It would be helpful if you could share what's the result when you do
whos arr x
Richard Poley
on 30 Jan 2017
Richard Poley
on 30 Jan 2017
Geoff Hayes
on 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
on 30 Jan 2017
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!