How to call a symbolic function from a Simulink's MATLAB Function block?
1 次查看(过去 30 天)
显示 更早的评论
So I have this complicated interpolating symbolic function that is in my workspace that I am trying to call from my Simulink module to use, is that possible? If so, how can I do that?
Because currently what I am doing is that I saved that symbolic function in a .mat file and I am loading it in my Simulink module each time I would like to use it in my MATLAB Function block. But is there a way to load that symbolic function once to my matlab basic workspace, and then from it call my symbolic function in my MATLAB Function Block ?
An example of a symbolic function: F = @(x) x^2
0 个评论
采纳的回答
Steven Lord
2023-6-26
An example of a symbolic function: F = @(x) x^2
No, as written that's an anonymous function not a symbolic function. Depending on how pedantic you want to be a symbolic function could be something like either g or f(x) in the code below:
syms x y f(x)
g = x.^2+y.^3
f(x) = sin(x+1)
whos x y g f
If what you have is more like g or f the matlabFunctionBlock function may be of use to you. Use that function to generate the block to use in your model.
If that's not what you mean by "symbolic function" please show us exactly how you create your symbolic function.
3 个评论
Steven Lord
2023-6-26
If you have a 10 MB anonymous function, perhaps you should write it as a regular MATLAB function file instead.
If most of that is data used by the file, I'm not 100% certain but you may want to look at storing that data somewhere other than a MAT-file. This documentation page and this other documentation page may be of use in determining the right place to store that data for your MATLAB Function block to use.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!