Coder - Static size string in sprintf
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
amin ya
am 7 Mär. 2019
Bearbeitet: amin ya
am 8 Mär. 2019
How can I prevent MATLAB Coder to generate variable size code for a simple number insertion into a string?
for i=1:4
name=sprintf('Data%d.bin',int8(i));
stuff(name)
end
In the generated C code it uses a lot of functions like emxutil to determine the size of the generated string for sprtintf.
I just want to say that i is only one digit. How can I do that?!
The followings also do not work
name=['Data',char(i),'.bin'];
Using the following also gives an error for generating code that LHS is fixed sized but RHS is varying:
coder.varsize('name',[1,14],[0,0])
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 7 Mär. 2019
Bearbeitet: Walter Roberson
am 7 Mär. 2019
If you know that it is a single digit then do not use that technique. Instead you can use
name = ['Data', char(i+'0'), '.bin']
Or if you really need to
name = 'DataX.bin';
name(5) = char(i+48);
1 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu MATLAB Coder finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!