Writing few data in Excel in one sheet
Info
This question is closed. Reopen it to edit or answer.
Show older comments
Hello. I have read a few image and RGB values (seperate to one column, without some pixel values, but thats not matter) for about 30 images from one folder. How to put all this data in one sheet, to begin in second row A2 and cetera... Here is my code:
allImages=dir(pwd)
for f=1:size(allImages)
if ~allImages(f).isdir
x2=imread(allImages(f).name);
redChannel = x2(:, :, 1);
greenChannel = x2(:, :, 2);
blueChannel = x2(:, :, 3);
matricaB=[];
A=size(blueChannel)
kolone=A(1)
vrste=A(2)
for i=1:kolone
for j=1:vrste
if redChannel(i,j)~=17 && greenChannel(i,j)~=24 && blueChannel(i,j)~=32
matricaB=[matricaB;redChannel(i,j) greenChannel(i,j) blueChannel(i,j)]
end
end
end
xlswrite('all-files.xlsx', matricaB, f);
end
end
This code put my values in separate sheets from sheet 3, don't know why, but this is not matter. I would like to store RGB values from first picture, 3 columns, from A2-C2, than RGB values from second picture from E2-G2, etc.
How to do that? Thanks!
1 Comment
Ivana
on 27 Nov 2016
Edited: Walter Roberson
on 27 Nov 2016
Answers (1)
Image Analyst
on 27 Nov 2016
You're doing:
xlswrite('all-files.xlsx', matricaB, f);
f is the sheet number, so the data will go into separate sheets. If you want to go into difference cell ranges on the same sheet, then you need to pass in a string with the cell reference:
xlswrite('all-files.xlsx', matricaB, 'A2');
Or you can pass in both the sheet name or number, AND the cell reference.
2 Comments
Ivana
on 27 Nov 2016
Image Analyst
on 27 Nov 2016
You need to construct the cell reference with sprintf() if it varies:
% Get a reference to the cell.
excelColumn = cell2mat(ExcelCol(startingColumn + columnNumber - 1));
cellReference = sprintf('%s%d', excelColumn, startingRow);
xlswrite('all-files.xlsx', matricaB, cellReference);
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!