Aris - what make you think that image is a valid field for x1_image? In your example, you save the A variable to the 80s.mat file and so when you load this file as
x1_image = load([x_folder,x_file]);
then the field for x1_image will be A. Your code would then be
A =imread('0001BG.tiff')
save('80s', 'A')
[x_file, x_folder] = uigetfile('*.mat', 'Select 80s-file');
x1_image = load([x_folder,x_file]);
cd(x_folder);
a80 = zeros(1024);
a80 = double(x1_image.A);
The above code is only valid if A is the variable that is always saved to the 80s.mat files. You could use fieldnames to get the list of fields of x1_image and your code might become A =imread('0001BG.tiff')
save('80s', 'A')
[x_file, x_folder] = uigetfile('*.mat', 'Select 80s-file');
x1_image = load([x_folder,x_file]);
structFieldnames = fieldnames(x1_image);
if ~isempty(structFieldnames)
cd(x_folder);
a80 = zeros(1024);
a80 = double(getfield(x1_image, structFieldnames{1}));
end
Here I'm assuming that the first fieldname corresponds to the image of interest...
Best Answer