how to implement symbolic matlab function on simulink?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Nicolas Schmit
le 18 Oct 2017
Simulink works only with numerical data. Why do you need to use the Symbolic Toolbox in a MATLAB function?
Réponses (1)
Sean de Wolski
le 2 Nov 2017
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/179121/image.png)
5 commentaires
Walter Roberson
le 2 Nov 2017
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))
Voir également
Catégories
En savoir plus sur Simulink Functions dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!