フィルターのクリア

Creating Headers for xlswrite

5 ビュー (過去 30 日間)
itend
itend 2017 年 9 月 4 日
コメント済み: itend 2017 年 9 月 4 日
Hello,
I am trying to create headers for data I am exporting from my code to excel. I want to have matlab print "ROI #1" in cell A2 of excel, "ROI #2" in A3, "ROI #3" in A4, etc. Here is what I have so far:
roi_count(1:(length(props{1})),1) = {'ROI #'};
roi_label(:,1) = num2cell(1:length(props{1}));
row_header = cellfun(@(x,y) [x y],roi_count,roi_label,'un',0);
range = 'A2'
xlswrite('advanced_test.xlsx',row_header,'Sheet1',range);
This gets close to what I want, however, the code prints "ROI #[]" in each cell within excel. I feel like I need to add a convert to string or something like that... unsure how to proceed. Please help!
Thanks :)

採用された回答

Walter Roberson
Walter Roberson 2017 年 9 月 4 日
row_header = cellstr( num2str( (1:length(props{1})).', 'ROI #%d' ) ) .'
If you have R2017a or later you can use
row_header = cellstr( "ROI #" + (1:length(props{1})) );
If you have R2016b you can use
row_header = cellstr( string('ROI #') + (1:length(props{1})) );
  1 件のコメント
itend
itend 2017 年 9 月 4 日
Fantastic. Thank you for your help :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by