user1640255
user1640255

Reputation: 1304

MATLAB 3D matrix save to TIFFs (2D)

In Matlab I have a 3D matrix (AxBxT), A by B data in a grid over a period of time T.

I would like to create a number of T, 2D arrays, or TIFF files (rasters) of AxB and save them using a loop with a different name.

what I done:

load matrix.mat
for i=1:T
  tiff = matrix(:, :, i);
  outputFileName = sprintf('smb%d.tiff', i);
  imwrite(tiff,outputFileName,'WriteMode', 'append')
end

but I cant make it work,

any idea/help is more than welcome

Upvotes: 2

Views: 4457

Answers (1)

anon01
anon01

Reputation: 11181

All you have to do is convert the matrix to a double format then, using double(). This should work:

load matrix.mat
matrix = double(matrix);
for i=1:T
  tiff = matrix(:, :, i);
  outputFileName = sprintf('smb%d.tiff', i);
  imwrite(tiff,outputFileName,'WriteMode', 'append')
end

Upvotes: 1

Related Questions