Question about S function
Ältere Kommentare anzeigen
Hi,
Is it possible to realize the following with Level 2 S function?
The input is a binary data, that is, every time only one bit can be read. The output shall save up to 10 bit and give them out. In this case the sample times at the input and at the output are different.
The problem is, in S function "block.InputPort(1).Data" is only valid for the current sample time.
Thanks Senmeis
Akzeptierte Antwort
Weitere Antworten (1)
Owen
am 11 Okt. 2012
3 Kommentare
Kaustubha Govind
am 11 Okt. 2012
Owen: The line "number=1" basically means that every time the Update method runs, number is assigned to 1 - even though you increment it towards the end of the function, that variable goes out of scope at the end of the Update function. I would recommend that you create another DWork to store the "number" value, so the value doesn't go out of scope by the next iteration.
Owen
am 13 Okt. 2012
Kaustubha Govind
am 16 Okt. 2012
Owen: You cannot change the size of DWork vectors at runtime. It is best to initialize it to a vector of 10 zeros and gradually fill it in.
Kategorien
Mehr zu Schedule Model Components finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!