How can I use integral in Matlab Function Block

3 ビュー (過去 30 日間)
thuan vu duc
thuan vu duc 2018 年 3 月 31 日
編集済み: Birdman 2018 年 3 月 31 日
Hello,
I'm trying to use "integral" function in "matlab function" in simulink. My code is:
function y = fcn(u)
syms x;
f = @(x)x;
y = integral(f,0,2);
But it has some errors:
The function 'syms' is not supported for standalone code generation. See the documentation for coder.extrinsic to learn how you can use this function in simulation.
Function 'MATLAB Function' (#57.20.27), line 2, column 1:
"syms x;"
Launch diagnostic report.
Component: MATLAB Function | Category: Coder error
Anonymous functions are not supported for code generation.
Function 'MATLAB Function' (#57.32.33), line 3, column 5:
"@"
Launch diagnostic report.
Component: MATLAB Function | Category: Coder error
Undefined function or variable 'f'. The first assignment to a local variable determines its class.
Function 'MATLAB Function' (#57.52.53), line 4, column 14:
"f"
Can you help me?
Thank you very much.

採用された回答

Birdman
Birdman 2018 年 3 月 31 日
編集済み: Birdman 2018 年 3 月 31 日
Simulink only works with numerical data. You can not use Symbolic Toolbox inside Simulink.
Since Simulink has its own timer, the integration will only be respect to time inside Simulink, by using Integrator block.

その他の回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by