MATLAB Answers

fwrite and fread: different dimensions for the same matrix

15 views (last 30 days)
Simon Lind
Simon Lind on 20 May 2015
Commented: Simon Lind on 20 May 2015
I’m trying to save a 2160x4320 matrix as
>> fid = fopen([Path filename '.bin'],'wb');
>> fwrite(fid,filename,'uint8');
>> fclose(fid);
% with Path and filename = char
But it only saves a 12x1 vector, where am I wrong?
Thank you in advance


Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 20 May 2015
Because you're writing out the filename string , not the matrix.
fwrite(fid, yourMatrix,'uint8');
By the way, since this appears to be a uint8 image, why not use imwrite() and use a standard image file format such as PNG? Why use .bin and fwrite()?

More Answers (0)

Sign in to answer this question.