Using 'char' within an embedded matlab function (simulink)

조회 수: 3 (최근 30일)
Rhonda Jordan
Rhonda Jordan 2011년 12월 1일
Hi Everyone,
When implementing the following code in a regular m file, I get no error:
data = zeros(16,1);
new_gens = char('Tegeta','Ngaka','Kiwira_1','Mchuchuma','Mufindi','Kinyerezi','Ubungo_Dar','Mwanza','Nyasa_Coal','Kihansi_2','Mpanga','Masigira','Ruhudji','Rumakali','Ikondo','Taveta');
filename2 = 'built_new.txt';
fid = fopen(filename2, 'w');
for i = 1:16
fprintf(fid,'pBuilt("%s") = %d;\r\n',new_gens(i,:),data(i));
end
fclose(fid);
However, when I use the same code within an embedded matlab function within simulink, I obtain the following error:
This call-site passes more inputs to this function than it can accept.
I checked that 'char' can be used within such simulink functions and it should work just fine. Do you know how to fix this?
I also tried making 'char' an extrinsic function and I received an error stating that the particular line was ignored since 'char' can be used within the simulink function. It then gave me an error stating:
subscripting into an mxArray is not supported
Again, I'm not sure what to do here so your help would be greatly appreciated!
Rhonda

답변 (1개)

Walter Roberson
Walter Roberson 2011년 12월 1일
Simulink does not support signals of type char . You need to use a vector of the numeric values of the characters. For example,
0 + 'What''s up, Doc?'

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by