ssGetPWork doesnt work in callbacks mdlInitializeSizes and mdlInitializeSampleTimes
显示 更早的评论
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.
回答(1 个)
Kaustubha Govind
2011-2-16
0 个投票
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 个评论
Giulio
2011-2-16
Kaustubha Govind
2011-2-17
In that case, ssSetUserData and ssGetUserData might be more appropriate.
类别
在 帮助中心 和 File Exchange 中查找有关 Configure C/C++ S-Function Features 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!