Obtain variable name in TLC
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Alexander Sinn
am 22 Jul. 2022
Kommentiert: Alexander Sinn
am 25 Jul. 2022
I am creating a TLC file for my S-Function and I would like to produce c-code to determine the size of my vector-output-signal array via the sizeof function.
However, both LibBlockInputSignalAddr(0, "", "", 0) and LibBlockInputSignal(0, "", "", 0) only return a reference to the first element of the output signal, thus, sizeof will only return the size of one element of the corrsponding array:
sizeof testModel_Y.Outport[0]
Instead I would like to achieve:
sizeof testModel_Y.Outport
Is it possible generate this statement using a TLC file?
0 Kommentare
Akzeptierte Antwort
Andy Bartlett
am 22 Jul. 2022
Consider doing it in two parts
bytes = LibBlockInputSignalWidth(0) * sizeof( LibBlockInputSignal(0, "", "", 0) )
Weitere Antworten (1)
Walter Roberson
am 25 Jul. 2022
In C,
sizeof testModel_Y.Outport
is the size of the pointer contained in testModel_Y.Outport . Multiplying the size of one element by the number of elements is the standard way to measure size of an array in C.
Siehe auch
Kategorien
Mehr zu Target Language Compiler finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!