MATLAB Answers


How to open .raw files in Matlab

Asked by Joaquim on 30 Nov 2016
Latest activity Commented on by Swati Jain on 31 May 2018
Accepted Answer by Jan
Hi everybody, I have a 3D image stored in a .raw format, 32 bits floating point, uncompressed. The dimensions are 288x288x400. How can I open this image in Matlab?
Thanks in advance, Joaquim Costa

  1 Comment

Hi, I am also trying to import an image in .raw format. My question is that, how did you know the dimensions and other details of your image?

Sign in to comment.

1 Answer

Answer by Jan
on 30 Nov 2016
Edited by Jan
on 1 Dec 2016
 Accepted Answer

fid = fopen(FileName, 'r);
if fid == -1
error('Cannot open file: %s', FileName);
data = fread(fid, 288*288*400, 'float32');
data = reshape(data, [288, 288, 400]);


How are you doing the displaying? After you display, is get(gca, 'YDir' set to normal or reverse?
on 1 Dec 2016
@Joaquim: How do you apply flipud on a 3D-array? Please post you code instead of describing it.
R2014a redefines flipud, fliplr, rot90 to be able to handle arrays with multiple dimensions.

Sign in to comment.