Dynamically sized outputs / work vectors using the Legacy Code Tool

8 次查看(过去 30 天)
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

采纳的回答

Kaustubha Govind
Kaustubha Govind 2012-3-2
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 个评论
Agamemnon Krasoulis
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?

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by