ssGetPWork doesnt work in callbacks mdlInitializeSizes and mdlInitializeSampleTimes
Ältere Kommentare anzeigen
Hello to everyone,
can somebody tell me why in sfunctions I can not store an object in the callbacks mdlInitializeSizes and mdlInitializeSampleTimes? It works in all the other callback.
the code looks like this
static void mdlInitializeSizes(SimStruct *S)
{
ssSetNumPWork(S, 1); // or ssSetNumPWork(S, DYNAMICALLY_SIZED);
.....
ssGetPWork(S)[0] = (void *) new MyClass;
}
Thank you!
G.
Antworten (1)
Kaustubha Govind
am 16 Feb. 2011
0 Stimmen
I don't believe that work vectors are even allocated until after mdlSetWorkWidths - mdlInitializeSizes and mdlInitializeSampleTimes are in the initialization stage of the S-function where attributes of work vectors can be set (like the number of work vectors, their widths, etc.) which can later be used for allocation.
Is there a reason you'd like to initialize your work vectors so early?
2 Kommentare
Giulio
am 16 Feb. 2011
Kaustubha Govind
am 17 Feb. 2011
In that case, ssSetUserData and ssGetUserData might be more appropriate.
Kategorien
Mehr zu Creating, Deleting, and Querying Graphics Objects 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!