Append character array to first row of a matrix
Ältere Kommentare anzeigen
Hi there!
I've the following struct array
Astruct =
struct with fields:
data1: [10×5 double]
data2: [10×5 double]
I would like to append a column header to the values stored in the above-metnioned struct before writing to an excel sheet.
data1_header = [1,3,2,4,5];
data2_header = [1,2,3,4,10];
Astruct =
struct with fields:
data1: [10×5 double] % header 'col' + data1_header : ['col1','col3','col2','col4','col5'];
data2: [10×5 double] % ['col1','col2','col3','col4','col10']
Any suggestions on how to do the above will be of great help
4 Kommentare
Numeric matrices do not have headers like that.
You could use a table, which do have headers:
E.g. use array2table and provide those header names as a string array, then writetable.
Or you could convert the numeric data to a cell array and append the header, but that is a bit... ugly.
If the only purpose of that header is to write it to an extrernal file, then you could just call two functions:
- writecell for the header. and then
- writematrix for the numeric data.
You would need to supply appropriate cell addresses, etc.
Deepa Maheshvare
am 20 Mai 2020
Bearbeitet: Deepa Maheshvare
am 20 Mai 2020
Deepa Maheshvare
am 20 Mai 2020
Walter Roberson
am 20 Mai 2020
Writemode is new as of R2020a.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Spreadsheets finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!