thanks, but i can't fixed it. I define the output sizes for the extrinsic call (without this was error). Now i have: Undefined function 'gfdeconv' for input arguments of type 'double'. String and double are allowed for input arguments. Trasform to string does not help.
function
[q,rem] = fcn(b,a)
coder.extrinsic(
'gfdeconv'
)
If you're getting an erro that gfdeconv is an undefined function, then there is some other problem. But you showed in the Question that you do have gfdeconv in your installation, so I don't know what's going on there.
This worked for me in Simulink:
function
[q,r] = fcn(b,a)
coder.extrinsic(
'gfdeconv'
)
[q,r] = gfdeconv(reshape(b,1,[]),reshape(a,1,[]));
It looks like if the Constant blocks have the "Intepret vector parameters as 1D" checked, then b and a come into the fcn as column vectors. But they have to be row vectors for gfdeconv, hence the reshapes. You can probably uncheck those boxes in the Constant blocks, and then they'd come in as row vectors, but I didn't try that. Or you could probably go to "Edit Data" in the function editor and explicitly set the sizes of b and a.
What I don't like is that q and r have to be pre-allocated to the exactly correct size. So there will be a problem if changes to b and/or a result in a change to the size of q and/or r.
I'm not sure how to get around that problem. I don't know enough about gfdeconv to know if numel(q) and numel(r) can be determined from numel(b) and numel(a), or even if they can if Simullink would allow q and r to be allocated based on some function of numel(b) and numel(a).
Sorry, I can't download and run a model.
The function I posted above works for me, feeding b and a with Constant blocks and sending q and r to Display blocks.
BTW, I wouldn't use rem as a variable name; it's a built-in function (
rem
).
If your model is as simple in the original Question, maybe you can post a screen shot of the block diagram, the code in fcn, and a screen shot of the error message that shows up in in the Diagnostic viewer after clicking Update or Play.
My experimentation showed that q and r have to be pre-allocated to the exact size as returned from gfdeconv.
The only think I can think of is to write a wrapper function that calls gfdeconv and stuffs the results into large, fixed-size vectors. So, a function like this assuming that the largest ever needed for q and r is eight elements.
function
[q,r] = gfdeconvwrapper(b,a)
q = [zeros(1,8 - numel(qq)) qq];
r = [zeros(1,8 - numel(rr)) rr];
With that function somewhere on the Matlab path, fcn in the Simulink model looks like this
function
[q,r] = fcn(b,a)
coder.extrinsic(
'gfdeconvwrapper'
)
[q,r] = gfdeconvwrapper(reshape(b,1,[]),reshape(a,1,[]));
In this way, q and r output from fcn will always have eight elements, regardless of the size of the output from gfdeconv. Increase from eight if needed. Hopefully, the zero-padding on the left won't have any impact on the rest of the model.
Find the treasures in MATLAB Central and discover how the community can help you!