Using 'char' within an embedded matlab function (simulink)
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponses (1)
Walter Roberson
le 1 Déc 2011
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?'
0 commentaires
Voir également
Catégories
En savoir plus sur Simulink Coder dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!