csvLoad - %usage: st = csvLoad(ch,cell) data = csvread(ch);...

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

View Full Document Right Arrow Icon
function st = csvLoad(ch,cell) % Given the filename of a csv file, write a function csvLoad that will % read in data from a csv file and store it in a structure array. Each % line from the csv file will be a structure in the structure array. % Each column of numbers will be a field in the structure array. The % name of each field will be determined by the second input, which will % be a cell array of column headers to be used as field names. You can % assume the headers will be valid field names.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %usage: st = csvLoad(ch,cell) data = csvread(ch); %reads in the data from the csv file [r c] = size(data); %determines the rows and columns of the data obtained st = ; %creates an empty vector to place values into for x = 1:r %runs the number of desired structures for y = 1:c %runs the desired number of fields st(x).(cell{y}) = data(x,y); %indexes the x structure with the y cell index and sets it equal to %the corresponding data end end end...
View Full Document

This note was uploaded on 10/21/2010 for the course CS 1371 taught by Professor Stallworth during the Spring '08 term at Georgia Tech.

Ask a homework question - tutors are online