Borrar filtros
Borrar filtros

Putting a cell into a .mat file

14 visualizaciones (últimos 30 días)
Trevor Arino
Trevor Arino el 24 de Abr. de 2023
Respondida: Walter Roberson el 24 de Abr. de 2023
I have an cell which contains images that I would like to put into a .mat file so I can export it into another software. I cannot figure out how to save my cell of images into a .mat file? Is there an easy way to do this?
%% Loading images
% Checking how many items are in the folder
num_images = dir(['Images' '\*.tif']);
num_images = numel(num_images);
%% Compiling images into .mat file
list = dir("Images\*.tif");
filenames = {list.name};
pathnames = {list.folder};
for i = 1:num_images
filename = filenames{i};
pathname = pathnames{i};
ImagesToSave{i} = imread(fullfile(pathname, filename));
end
save('test.mat', ImagesToSave{:})
Undefined variable 'ImagesToSave'.

Respuestas (2)

Kevin Holly
Kevin Holly el 24 de Abr. de 2023
save('test.mat', 'ImagesToSave')

Walter Roberson
Walter Roberson el 24 de Abr. de 2023
%% Loading images
imgfolder = 'Images';
% Checking how many items are in the folder
list = dir( fullfile(imgfolder, '*.tif'));
num_images = numel(list);
%% Compiling images into array
fullnames = fullfile({list.folder}, {list.name});
ImagesToSave = cell(num_images,1);
for i = 1:num_images
thisfile = fullenames{i};
ImagesToSave{i} = imread(thisfile);
end
%save as .mat file
save('test.mat', 'ImagesToSave')

Categorías

Más información sobre Install Products en Help Center y File Exchange.

Productos


Versión

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by