Code covered by the BSD License  

Highlights from
Demo Files for "Data Analysis with Statistics and Curve Fitting Toolboxes" 2007 Webinar

image thumbnail

Demo Files for "Data Analysis with Statistics and Curve Fitting Toolboxes" 2007 Webinar

by

 

08 Aug 2007 (Updated )

Demo file from the August 7, 2007 Live Webinar

importfile(fileToRead1)
function importfile(fileToRead1)
%IMPORTFILE(FILETOREAD1)
%  Imports data from the specified file
%  FILETOREAD1:  file to read

%  Auto-generated by MATLAB on 27-Jul-2007 07:18:17

% Import the file
newData1 = importdata(fileToRead1);

% For some XLS and other spreadsheet files, returned data are packed
% within an extra layer of structures.  Unpack them.
fields = fieldnames(newData1.data);
newData1.data = newData1.data.(fields{1});
fields = fieldnames(newData1.textdata);
newData1.textdata = newData1.textdata.(fields{1});
fields = fieldnames(newData1.colheaders);
newData1.colheaders = newData1.colheaders.(fields{1});

% Break the data up into a new structure with one field per column.
colheaders = genvarname(newData1.colheaders);
for i = 1:length(colheaders)
    dataByColumn1.(colheaders{i}) = newData1.data(:, i);
end

% Create new variables in the base workspace from those fields.
vars = fieldnames(dataByColumn1);
for i = 1:length(vars)
    assignin('base', vars{i}, dataByColumn1.(vars{i}));
end

Contact us