MATLAB: How to automatically save the extracted features from images in a single excel file

image processingsave

I have extratced some features from medical images which I have segmented the preferred ROI and divided into four quadrants. Thus each image is having four quadrants and I have extraced all of six features from each of these quadrant image. Can you help me how to automize this code to save the extracted features i a single excel .xlsx file? Thanks in advance.
Here is my code;
%Load the current directory
MyFolder = 'C:\Users\User\Documents\MATLAB\CXR Images\Local DB\NHRD_IMAGES';
% Get the list of all images in the folder with the desired file name pattern
FilePattern = fullfile (MyFolder, 'NHIMG-*.jpg');
TheFiles = dir (FilePattern);
for k = 1 : length(TheFiles)
BasefileName = TheFiles (k).name;
FullFileName = fullfile (MyFolder, BasefileName);
fprintf (1, 'Now reading %s\n', FullFileName);
% Read in the CXR images
I= imread (FullFileName);
% Segmentation of the lung field from the CXR image
[S] = LungMask(I);
% Dividing Segmented lung image into quadrants
[RUQ, LUQ, RLQ, LLQ] = crop(S);
% Extracting Features from each quadrant of the segmented images
[Stats, MaxProb, Entropy] = Prop(RUQ);
[Stats, MaxProb, Entropy] = Prop(LUQ);
[Stats, MaxProb, Entropy] = Prop(RLQ);
[Stats, MaxProb, Entropy] = Prop(LLQ);
end

Best Answer

Put them into 4 different variables, then call xlswrite or writematrix():
[Stats1, MaxProb1, Entropy1] = Prop(RUQ);
[Stats2, MaxProb2, Entropy2] = Prop(LUQ);
[Stats3, MaxProb3, Entropy3] = Prop(RLQ);
[Stats4, MaxProb4, Entropy4] = Prop(LLQ);
xlswrite(fileName, Stats1, 'Sheet1', 'A1')
xlswrite(fileName, Stats2, 'Sheet2', 'A1')
xlswrite(fileName, Stats3, 'Sheet3', 'A1')
xlswrite(fileName, Stats4, 'Sheet4', 'A1')