필터 지우기
필터 지우기

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
Agamemnon Krasoulis 2012년 3월 6일
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 2012년 3월 6일
OK, just found it. Thanks a lot for your help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by