calling a matlab function with scalar type
显示 更早的评论
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 个评论
Geoff Hayes
2017-1-30
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
2017-1-30
It would be helpful if you could share what's the result when you do
whos arr x
Richard Poley
2017-1-30
Richard Poley
2017-1-30
Geoff Hayes
2017-1-30
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
2017-1-30
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!