File Output format not in Hex in Designer, but is in .m file output
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Scotty Mac
am 14 Sep. 2023
Bearbeitet: Scotty Mac
am 14 Sep. 2023
I am using Matlab 2019a Designer to dump some values to a text file. If I run the .m file on the command line (like a normal Matlab function), it outputs the data in hex format, as expected.
If I use the designer app and dump the data, it saves the data in decimal format. How can I get the output of my data to be in hex format like the .m file? Thanks!
Here is my code snippet:
% Format the coefficients in .mem format
Nd = Nf/Nl; % Word depth of memory for each vector
fd = fopen(fn, 'w');
fprintf(fd, '// SHAPE vector ROM for %s, contains %d vectors, each %d samples\n', band, K, Nf);
for k = 1 : K
for n = 0 : Nd-1
fprintf(fd, '@%04x ', Nd*(k-1)+n);
for m = Nl-1 : -2 : 1
data = xq(Nl*n+m+1,k)*pow2(3*Qc) + xi(Nl*n+m+1,k)*pow2(2*Qc) + xq(Nl*n+m,k)*pow2(Qc) + xi(Nl*n+m,k);
fprintf(fd, '%09x', data);
end
fprintf(fd, '\n');
end
end
fclose(fd);
4 Kommentare
Walter Roberson
am 14 Sep. 2023
As an experiment, try
fprintf(fd, '%09x', round(data));
Akzeptierte Antwort
Walter Roberson
am 14 Sep. 2023
Bearbeitet: Walter Roberson
am 14 Sep. 2023
reading off of your tooltip and converting:
format long g
g = hex2num('422ffbed66dbfd86')
Not an integer.
The problem is not with output facilities: the problem is that somehow you are calculating differently.
3 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Type Conversion 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!