Data not saving in excel spreadsheet.
Mostra commenti meno recenti
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 Commenti
You seem to be mixing together a lot of bits and pieces in this question to the extent I can't really understand what you are asking. You talk about saving to a spreadsheet, but then move on to say that you earlier save a cell array which does not open because Matlab says the directory doesn't exist. This seems fairly significant, but then you just move on with some code that appears not to be related either to saving the cell array nor loading it or saving the Excel file.
It is much easier to get help if you focus in on the problem. Code to calculate 'something' has no bearing on saving to Excel unless the 'something' ends up empty, in which case the saving to Excel is not relevant. Equally, if the data that is important is in the supposedly saved cell array in the directory which doesn't exist then this seems to be the key issue.
Aaron Smith
il 11 Ago 2017
Adam
il 11 Ago 2017
Well the first obvious question is 'Does the mat file actually exist after you have saved it?'.
I don't really see how an error saying a directory doesn't exist could be in any way related to the calculation of the data that you supposedly saved there though.
Using the debugger will quickly tell you whether the data you have at the point you call save is sensible or not. Looking in Windows explorer will quickly tell you if the mat file was saved correctly or not. If the answer to both of these is yes then the problem comes somewhere between saving and trying to load the data again.
Aaron Smith
il 11 Ago 2017
Aaron Smith
il 14 Ago 2017
Modificato: Aaron Smith
il 14 Ago 2017
Adam
il 14 Ago 2017
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.
Risposte (0)
Categorie
Scopri di più su Spreadsheets in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!