admin管理员组

文章数量:1294523

  1. 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?
  2. 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.

  1. 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?
  2. 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 badges
Add a comment  | 

1 Answer 1

Reset to default 0

There 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));

本文标签: