Code covered by the BSD License  

Highlights from
Demo files for "MATLAB for Excel Users" webinar

image thumbnail

Demo files for "MATLAB for Excel Users" webinar

by

 

27 Aug 2010 (Updated )

This is the demo used in March 22, 2011 webinar "MATLAB for Excel Users".

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

%  Auto-generated by MATLAB on 24-Sep-2009 22:05:41

% Copyright 2010 The MathWorks, Inc.

% Import the file
sheetName='Sheet1';
[numbers, strings] = xlsread(fileToRead1, sheetName);
if ~isempty(numbers)
  newData1.data =  numbers;
end
if ~isempty(strings)
  newData1.textdata =  strings;
  newData1.colheaders =  strings;
end

% Break the data up into a new structure with one field per column.
colheaders = genvarname(newData1.textdata);
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