Matrix as output in an S-function
이전 댓글 표시
Hi, I'm trying to put a matrix in the output of an s-function but I'm getting following error:
In an assignment A(I) = B, the number of elements in B and I must be the same.
I think because I'm writing a matrix where Matlab expects a constant...
I think this is the relevant code:
sizes.NumOutputs = NumberOfOutputs;
...
[sys,next_state] = updateFSM(x,u);
...
function [NumberOfInputs,NumberOfOutputs,InitialState]=initFSM()
NumberOfOutputs = 2;
...
function [Output,next_state]=updateFSM(state,Input)
CS = 1;
STROOM = zeros(1,10);
...
Output(1) = CS;
Output(2) = STROOM;
Is it possible to output a matrix (with a fixed dimension of 10 bits)?
My S-function is importing one bit each clock cycle and storing it in a matrix. After 10 clock cycles the resulting matrix should be exported.
Thanks in advance!
답변 (1개)
Walter Roberson
2011년 11월 30일
Change
Output(2) = STROOM;
to
Output(2:11) = STROOM;
If you want CS and STROOM to be distinct from each other, then your routine has three outputs rather than the 2 your code claims.
댓글 수: 4
Robbe
2011년 11월 30일
Walter Roberson
2011년 11월 30일
Your code appears to be at least partly in Level-1 S-Function form. You must decide between Level-1 or Level-2 as their calling protocols are quite different.
http://www.mathworks.com/help/toolbox/simulink/sfg/f7-67615.html#f7-59576
Kaustubha Govind
2011년 12월 1일
Robbe: Walter's solution is a single vector which has 11 elements - the first element is CS and the remaining 10 elements comes from STROOM.
Robbe
2011년 12월 1일
카테고리
도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!