How to invert the function typecast?
Ältere Kommentare anzeigen
Hello,
I am using typecast to convert from double to uint8 and store some data in a file:
fwrite(fid,typecast(double(data),'uint8'),'uint8');
Now, I want to read this data back, but if I use fread like this:
data2 = fread(fid, length(data), 'double');
when it finds a value equivalent to a new line (10) or carriage return (13) - I am not sure which one of those actually is - it corrupts the data read after that value.
How can I avoid this problem? I need to write the data using uint8 because I need to read it from an ARM, process it, write it back, and read it in Matlab.
I do not know if there is a better way of doing all this.
Thanks!
3 Kommentare
Dani Tormo
am 20 Apr. 2016
James Tursa
am 20 Apr. 2016
Bearbeitet: James Tursa
am 20 Apr. 2016
Please show all of your relevant code, including your fopen statements, what is the class and size of the variable data, all of your fwrite and fread statements, etc.
Dani Tormo
am 20 Apr. 2016
Bearbeitet: Dani Tormo
am 20 Apr. 2016
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Spreadsheets finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!