필터 지우기
필터 지우기

How to numericaly integrate in simulink-block "matlab function" block

조회 수: 1 (최근 30일)
Daniel Peters
Daniel Peters 2017년 6월 19일
답변: Jatin Waghela 2017년 6월 22일
Hello,
I'm trying to use "integral" function in "matlab function" in simulink. You can reduce the code to:
function f=fun(x)
coder.extrinsic('syms');
coder.extrinsic('integral');
xmin=0
xmax=1
k=@(x)x
syms x
f=integral(k, xmin, xmax)
end
So when I use this, the error following error occures: "Cannot pass an object of class 'function_handle' to MATLAB function 'integral'". When I try to put in the Function k itself into the integral the error stays the same. When I delete the "@(x)" the Error says that x is not defined.
Can you help me to make the integration work?
thank you

답변 (1개)

Jatin Waghela
Jatin Waghela 2017년 6월 22일
The code you provided seems to work fine for me when I run the code directly in MATLAB.
Please use the below command to ensure that there are no other functions names 'integral' what are being referred to instead of the correct 'integral' function.
which -all integral

카테고리

Help CenterFile Exchange에서 Modeling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by