my data in excel keep overwriting

2 ビュー (過去 30 日間)
Jonatan Morisson
Jonatan Morisson 2017 年 10 月 30 日
コメント済み: Jan 2017 年 11 月 2 日
hi guys this is my code
function GLCM()
directory = 'C:\Users\Jonatan Morisson\Desktop\Skhrip-shi\data\Fixed Data\Aseman';
files = dir([directory '\*.jpg']);
for x = 1:10
image{x} = imread([directory '\' files(x).name]);
image{x} = rgb2gray(image{x});
g1{x} = graycomatrix(image{x}, 'Offset', [-1 1]);
s1{x} = graycoprops (g1{x});
%c{x} = struct2cell(s1{x});
%xlswrite('name.xlsx', c{x);
xlFilename = 'C:\Program Files\MATLAB\MATLAB\bin\aaaa.xlsx';
xlRange = strcat(strcat(strcat('A',int2str(x+1)),':'),strcat('E',int2str(x+1)));
writetable(struct2table(s1{x}),xlFilename);
%xlswrite(xlFilename,struct2cell(s1{x}),'Sheet 1',xlRange);
disp (s1{x})
end
end
but my excel just like this :
can someone help me?? much thanks !!

回答 (1 件)

Jan
Jan 2017 年 10 月 30 日
編集済み: Jan 2017 年 10 月 30 日
We see the working code and the output, which is created exactly how the code does define it. To help you, we need an explanation what you want instead. Perhaps you want to use the range as in the commented code using xlsread?
writetable(struct2table(s1{x}), xlFilename, 'Range', xlRange);
What about creating a table with all results at first and write them at once after the loops? This is more elegant and probably faster.
  2 件のコメント
Jonatan Morisson
Jonatan Morisson 2017 年 10 月 31 日
sir i already got the answer,
writetable(struct2table(s1{x}), xlFilename,'Range', xlRange,'WriteVariableNames',0);
it always bring its row variable name now it works like a charm,
but sir can i ask one more question? can i put the name of the image file in the E1-E10 as the name of the feature? i already do another writetable with the files(x).name as the table but it got me error "Undefined function 'write' for input arguments of type 'char'." can u help me sir?
Jan
Jan 2017 年 11 月 2 日
Please post the failing line. "Undefined function 'write' for input arguments of type 'char'" sounds like you have written "write" instead of "writetable".

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

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by