Code covered by the BSD License  

Highlights from
Introduction to MATLAB® Webinar materials

Introduction to MATLAB® Webinar materials

by

 

20 Mar 2007 (Updated )

Presentation and demo materials from the live Webinar "Introduction to MATLAB®" (March 20, 2007)

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

% Copyright 2007 The MathWorks, Inc.

%  Auto-generated by MATLAB on 26-Jul-2006 12:56:12

% Import the file
newData1 = importdata(fileToRead1);

% 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('caller', vars{i}, dataByColumn1.(vars{i}));
end

Contact us