Codegen commands like this:
codegen -config:dll ep1 -args single(0) ep2 -args {0,0}
are easy for functions like this:
function y = ep1(u) %#codegen
y = u;
function y = ep2(u, v) %#codegen
y = u + v;
I am just wondering how to define scalar struct arguments. Let us assume that the above argument u should look like this (i.e. consist of 2 fields - one char and one double):
u.FirstName = 'Loren';
u.Height = 150
PS:
Just found something like this:
s = struct('a',42,'b',4711);
codegen topfun.m -args { s }
would this be a solution? I believe, this is a definition by example.
This seems to work for me:
codegen -report -config:dll ep1 ...
ep2
The actual 'function signature' (and thus scalar struct) can be defined in the function like this:
function [bla] = ep1(parameters)
%#codegen
assert(isstruct(parameters));
assert(isa(parameters.x1,'char'));
assert(size(parameters.x1, 1) >= 1);
assert(size(parameters.x1, 1) <= 1024);
assert(isa(parameters.x2,'double'));
...
Problem I have is that I seem to have to define all the parameters in the parent functions even-though I do not use the parameter in the parent function.
Looking at the stuff above. Let us say ep1 is the parent function of ep2 and ep1 does not use parameters.x2, I still have to assert it in ep1.Hope this makes sense.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With