Effacer les filtres
Effacer les filtres

Dynamically sized outputs / work vectors using the Legacy Code Tool

8 vues (au cours des 30 derniers jours)
Hello everyone,
I am trying to build an s - function using the Legacy Code Tool and I have the following problem:
I work with matrices and I want some of the outputs and work vectors to have a dynamically sized first dimension and a second dimension whose size depends on a parameter or input.
So, I want to do this one: (dynamically sized input u1, parameter p1)
def.OutputFcnSpec = 'void step2(double y1[size(u1,1)][size(u1,2)], double u1[][], int32 p1, int32 size(u1,1), int32 size(u1,2), double work1[size(u1,1)][p1], double y2[size(u1,1)][p1])';
But, the compiler does not allow that and I get the following error: "When specifying input/output/parameter/work dynamically sized, all dimensions must be dynamically sized (dwork 1)"
Does anyone have an idea of how I could do that?
Thank you very much in advance.
Agamemnon

Réponse acceptée

Kaustubha Govind
Kaustubha Govind le 2 Mar 2012
What you're looking to do is output a variable-size signal. Unfortunately, I don't think the Legacy Code Tool can handle generation of S-functions that produce variable-size signals. Perhaps you could generate the S-function for a fixed-signal signal first and then modify it manually to support variable-size signals. See here for an example of an S-function that supports this feature.
  2 commentaires
Agamemnon Krasoulis
Agamemnon Krasoulis le 6 Mar 2012
Thank you very much for your reply.
I will try to generate the C-MEX file using the Legacy Tool and then modify it manually, as you suggested.
Do you happen to know the difference between DYNAMIC_DIMENSION and DYNAMICALLY_SIZED when it comes to the signals (inputs, outputs and work vectors) dimensions definition?
Agamemnon Krasoulis
Agamemnon Krasoulis le 6 Mar 2012
OK, just found it. Thanks a lot for your help!

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by