Hi, everybody, I got one problem when using S-function dynamic output. The input dimensions of my S function module is constant, i.e., 4,

4 views (last 30 days)
Hi, everybody, I got one problem when using S-function dynamic output. The input dimensions of my S function module is constant, i.e., 4, But the dimensions of my output is dynamic, it is relative to but not the same as the values of one input. Thus, my question is how I set the number of dimension for output in a dynamic or variable way. And I check the matlab document, What it says is the dimension of output is needed to be the same as the dimension of input if we get to use variable output dimensions.

Answers (2)

Kaustubha Govind
Kaustubha Govind on 10 Aug 2012
You haven't mentioned if you're writing a MATLAB S-function, or a C S-function, but this page in the documentation points to demos for both types of S-functions with variable-sized outputs.
  13 Comments

Sign in to comment.


Yiqi Liu
Yiqi Liu on 12 Aug 2012
Tanks for your reply. Actully, I prefer to use Level-2 MALAB language S-function because all my sub-function are based on MALAB language. If it impossible, i have to use C Sfunction. The dimensions of my output depend on the calculation of one input value. That means, I should do a complicated calculation using that input value, then i can obtain how many dimensions of the output I should use. Is this possible?
  1 Comment
Sathish Kumar
Sathish Kumar on 10 Jun 2014
Yes you can get multi-dimensional output out of a 1D input. Just remember to set the correct output port dimension.( block.OutputPort(portid).Dimensions=dim, where dim=[m,n] for an mxn output.), It your outsize changes based on the logic in your program set the output port dimension to -1.

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!