Embedded Matlab function in Simulink with num2str function
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am using the following matlab embedded function in a Simulink Model. When I run the simulation I am getting an error "num2str is not supported for Code Generation "
Is there any way so that we can use all available matlab function is simulink??
function yy=fcn(u)
%%%ASCII Code Generation of Numbers of Characters
in_number=u ;
%%%Conveting the incoming number to String
in_string=num2str(in_number);
%%%creation of empty row to fill with ascii numbers
max_index=length(in_string);
out_ascii=zeros(1,max_index);
i=1;
for j=drange(in_string)
out_ascii(i)=abs(j); %%%ascii equivalent number of the string
i=i+1;
end
yy=out_ascii;
1 commentaire
Azzi Abdelmalek
le 21 Déc 2012
Modifié(e) : Azzi Abdelmalek
le 21 Déc 2012
Your input u is integer, double, negative ? also what is drange?
Réponses (2)
Atsushi Matsumoto
le 18 Oct 2017
Below code supports code generation.
function str = num2strc(num) %#codegen
str = [];
while num > 0
data = mod(num,10);
str = [char(48+data), str]; %#ok
num = (num-data)/10;
end
end
0 commentaires
Voir également
Catégories
En savoir plus sur Embedded Coder 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!