How to call a symbolic function from a Simulink's MATLAB Function block?
조회 수: 2 (최근 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!