How to export xls file from Matlab

2 ビュー (過去 30 日間)
Stelios Fanourakis
Stelios Fanourakis 2019 年 1 月 18 日
コメント済み: Stelios Fanourakis 2019 年 1 月 18 日
Hello
I use this code to get the sum of pixels for a certain area of an image
for col = col1 : col2
row2 = find(mask(:, col), 1, 'last'); % Get bottom row of mask
if ~isempty(row2)
% Get the sum in the GREEN channel, from row1 to row2.
grayLevelSum(col) = sum(greenChannel(topRow:row2, col));
% Compute the height of the mask at every column.
heights(col) = sum(mask(topRow:row2, col));
end
end
I also get the results like
Column 0:
0 0 23 23 22 22 21 100 112 113
Column 1:
99 99 87 88 84 32 23 22 21
Column 2:
113 114 155 165 166 210 222 255
... etc
What I want is a way to either have the column results vertically so I can copy and paste them in rows in an xls file or if there is a script to export them directly in rows,columns in xls file determined by me.
Thank you so much

採用された回答

Walter Roberson
Walter Roberson 2019 年 1 月 18 日
data = [grayLevelSum(:), heights(:)];
sheet = 1;
range = 'A:B';
xlswrite('YourFile.xls', data, sheet, range)
  1 件のコメント
Stelios Fanourakis
Stelios Fanourakis 2019 年 1 月 18 日
More or less yes. What I need. But why two columns (A:B) that have same values?
The numbered column before A, gives the number of columns in the image, then column A should give the sum number of pixels for the respective column. Why column B then? In my case, it is just a duplicate column of A, having the same values as column A.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImport, Export, and Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by