Azzera filtri
Azzera filtri

Creating Headers for xlswrite

5 visualizzazioni (ultimi 30 giorni)
itend
itend il 4 Set 2017
Commentato: itend il 4 Set 2017
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 :)

Risposta accettata

Walter Roberson
Walter Roberson il 4 Set 2017
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})) );

Più risposte (0)

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by