MATLAB: What is the meaning for variable of .mat file

.mat file

Hi, I have two colour image in .jpg. How can I convert them into 1 .mat file with only 1 variable like 2x28x28 array.
here is the code that i have try, but it generate 2 variable as below
  • pic1 = imread('image_0001.jpg');
  • pic1 = imresize(pic1, [28, 28]);
  • pic2 = imread('image_0002.jpg');
  • pic2 = imresize(pic2, [28, 28]);
  • save('BothPics.mat', 'pic1', 'pic2');

Best Answer

bothPics = cat(3, pic1, pic2); % Create 28x28x2 array
save(('BothPics.mat', 'bothPics');