File Exchange

image thumbnail

Convert Struct to Cell Array With Column Headers

version 1.0 (1.07 KB) by

Converts a populated struct into a cell array with field names as column headers

0 Downloads

Updated

No License

Accepts a 1-dimensional struct array (in the format 1xn) and converts it into a cell array. The first row of the cell array has the struct's field names in each column; the data from each of those fields for each entry in the struct array appears in subsequent rows. The idea is to make it easy to prep data for writing to an Excel spreadsheet using xlswrite.

Example:
weather =

1x3 struct array with fields:
temp
rainfall

>> wxcell = structToCellArrayWithHeaders ( weather )

wxcell =

'temp' 'rainfall'
[ 68] [ 0.2000]
[ 80] [ 0.4000]
[ 72] [ 0]

Comments and Ratings (0)

MATLAB Release
MATLAB 7.2 (R2006a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video