Embedded Matlab function in Simulink with num2str function

조회 수: 11 (최근 30일)
ALEXANDER KALE
ALEXANDER KALE 2012년 12월 21일
답변: Atsushi Matsumoto 2017년 10월 18일
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
Azzi Abdelmalek
Azzi Abdelmalek 2012년 12월 21일
편집: Azzi Abdelmalek 2012년 12월 21일
Your input u is integer, double, negative ? also what is drange?

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

답변 (2개)

Rick Rosson
Rick Rosson 2012년 12월 25일
eml.extrinsic('num2str');

Atsushi Matsumoto
Atsushi Matsumoto 2017년 10월 18일
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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by