xlsStore - for x = 1:length(headers) %because there will...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function st = xlsStore(ca) %function to read in the file and store the elements into a structure; the %column headers in the .xls file will correspond to the field names of the %stucture, while the data in each column will correspond to the data that %should be stored in the corresponding field of the structure %usage: st = xlsStore(ca) [num txt raw] = xlsread(ca); %gives the num text and raw data from the excel file headers = raw(1,:); %finds a cell array of all the column titles st = []; %creates an empty vector
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: for x = 1:length(headers) %because there will only be a certain number of fieldnames, the for loop must run from 1 %to the length of these fieldnames for y = 1:length(raw(2:end,x)) %this for loop will create the necessary number of structures st(y).(headers{x}) = raw{y+1,x}; %this will index the structure and give it the value of the x %header element; then set the particular header equal to the index %of the respective raw cell elements end end end...
View Full Document

Ask a homework question - tutors are online