admin管理员组文章数量:1294523
- I have tried to do this using a C caller block and then using C++ vectors, but the error that arises suggests C caller blocks do not support C++. Is this correct?
- Next I tried to use a Matlab Function block, with which I attempt to call code in my C file. However, it seems to object to calling a C function of multiple inputs with a coder.ceval statement and I'm just wondering if this is actually possible? If so, what should the syntax be?
I am doing this for someone else on their pc and do not have it on my pc, so can't see it right now, but as I recall, my effort was something like this:
function [a,b,c,d] = callingCcode (x,y)
x = coder.ceval('Ccode',(x,y))
It seems to object to the multiple inputs in the coder.ceval line, as I say. Having just taken a look at coder.ceval, I see it can only return a single scalar output. I want it to return more than one double as an output, so I'm just wondering if it's not possible this way and if so, whether there's any other way to do this? What I'm seeking to do again is to have a block with multiple inputs and outputs which calls C Code.
- I have tried to do this using a C caller block and then using C++ vectors, but the error that arises suggests C caller blocks do not support C++. Is this correct?
- Next I tried to use a Matlab Function block, with which I attempt to call code in my C file. However, it seems to object to calling a C function of multiple inputs with a coder.ceval statement and I'm just wondering if this is actually possible? If so, what should the syntax be?
I am doing this for someone else on their pc and do not have it on my pc, so can't see it right now, but as I recall, my effort was something like this:
function [a,b,c,d] = callingCcode (x,y)
x = coder.ceval('Ccode',(x,y))
It seems to object to the multiple inputs in the coder.ceval line, as I say. Having just taken a look at coder.ceval, I see it can only return a single scalar output. I want it to return more than one double as an output, so I'm just wondering if it's not possible this way and if so, whether there's any other way to do this? What I'm seeking to do again is to have a block with multiple inputs and outputs which calls C Code.
Share edited Feb 13 at 13:04 Gee Tomlinson asked Feb 12 at 12:35 Gee TomlinsonGee Tomlinson 1,9413 gold badges18 silver badges33 bronze badges1 Answer
Reset to default 0There are many things possible using coder.ceval
- including calling C++. But also many limitations. Currently working on this as well. You can call arrays, but there are limitations if you have typedefs that define array datatypes.
For inputs and outputs look into the use of coder.rref
and coder.wref
So in your example
function [a,b,c,d] = callingCcode (x,y)
% init output by reference variables
b = 0;
c = 0;
d = 0;
a = coder.ceval('Ccode', coder.rref(x), coder.rref(y), ...
coder.wref(b), coder.wref(c), coder.wref(d));
本文标签:
版权声明:本文标题:Is it possible to have a block with multiple outputs which also calls C code in Matlab Simulink? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741599850a2387633.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论