Data not saving in excel spreadsheet.

2 次查看(过去 30 天)
Aaron Smith
Aaron Smith 2017-8-11
评论: Adam 2017-8-14
I have a series of values stored in a cell array that I am saving as an excel spreadsheet. The code to make the excel file is working except for the fact that the spreadsheet is empty when opened. I suspect that this is due to the creation of the data earlier in the code. I have used regionprops to calculate the average intensity inside two regions of interest on a number of matrices stored in a cell array. I have saved the resultant cell array, which should be composed of two columns(the ROI) and a number of rows(the matrices), but when i attempt to open it Matlab claims the directory does not exist. The code to calculate this mean intensity is set up to create this cell array of mean intensity values and I cannot tell where the problem may arise.
for i = 1 : numel(Y)
X = Y{i}.*mask;
end
for i = 1 : length(X)
thisImage = X{i}; % Extract matrix from cell array of matrices.
%Get allIGLs for that image.
props = regionprops(thisImage, 'Area', 'MeanIntensity'); %get these properties for each of the cells in the array 1 : length(i)
allAreas = [props.Area]; % the areas are stored in an array
allMeans = [props.MeanIntensity]; % the means are stored in an array
allIGLs = allAreas .* allMeans; % % The average intensity is calculated
caIGLs{i} = allIGLs; % Store IGLs for this image into a cell array called caIGLs
end
My one suspicion was that rather than save each intensity value in its own discreet cell, the intensities were added together (summed) but the code is set up to calculate the intensity from each matrix individually. This suspicion arose as upon changing xlswrite(fullfile(Folder, Name), Cell_Array, Sheet); to xlswrite(fullfile(Folder, Name), Cell_Array{:}, Sheet); when creating the excel, where Cell_Array is the file created using regionprops (caIGLs)
  6 个评论
Aaron Smith
Aaron Smith 2017-8-14
编辑:Aaron Smith 2017-8-14
I have tried everything I can think of like specifying that the inputs are cell arrays as is shown in this Mathworks thread : Here
In every other loop for loop i've ever used, by specifying the number of files in the cell array it determines how many iterations are to be done. It appears that all of the iterations are being done but instead of saving the data in a cell array it is getting the sum of all 130 cells leaving only one cell for area and one cell per region for area, one cell per region for mean and when they are multiplied by each other, it again only has one cell for each region.
Adam
Adam 2017-8-14
You should probably change the title of the question if it is actually about regionprops and nothing to do with the Excel saving. It might get more attention from people who know about using regionprops.

请先登录,再进行评论。

回答(0 个)

产品

Community Treasure Hunt

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

Start Hunting!

Translated by