how to implement symbolic matlab function on simulink?

조회 수: 6 (최근 30일)
Fatma Abdullah
Fatma Abdullah 2017년 10월 17일
댓글: Walter Roberson 2017년 11월 2일
im trying to implement the following function on matlab function on simulink but error 'syms is not supported for a stand alone code generation' occures
function fkt = fcn(c,p,k,N)
syms t
ft=p^(-c/2)*(c/2)*t.^((c/2)-1).*exp(-(t./p).^(c/2));
Ft=1-exp(-(t/p).^(c/2));
fkt=k*nchoosek(N/2,k)*(1-Ft)^(N/2-k)*(Ft)^(k-1)*ft
end
  댓글 수: 2
Nicolas Schmit
Nicolas Schmit 2017년 10월 18일
Simulink works only with numerical data. Why do you need to use the Symbolic Toolbox in a MATLAB function?
Fatma Abdullah
Fatma Abdullah 2017년 10월 18일
um working on paper to try to simulate complicated system with calculations of integration and convolution that are almost impossible to be evaluated in matlab.....um taking the easy way instead of complicated matlab programing

댓글을 달려면 로그인하십시오.

답변 (1개)

Sean de Wolski
Sean de Wolski 2017년 11월 2일
You can do this by putting syms inside of a function called by a MATLAB Function block where the inner function is flagged as extrinsic:
  댓글 수: 5
Fatma Abdullah
Fatma Abdullah 2017년 11월 2일
i'm trying to generate code for standalone work, not in acceleration mode
Walter Roberson
Walter Roberson 2017년 11월 2일
In that case, extrinsic is not going to work, unfortunately. You will need to use a MATLAB Function block for at least the nchoosek; perhaps it would be easier to put it all into a MATLAB Function block to do the
(c*k*t^(c/2 - 1)*exp(-(t/p)^(c/2))^(N/2 - k + 1)*nchoosek(N/2, k)*(1 - exp(-(t/p)^(c/2)))^(k - 1))/(2*p^(c/2))

댓글을 달려면 로그인하십시오.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by