Code covered by the BSD License  

Highlights from
Mathematical Modeling with MATLAB Products - webinar demo files

image thumbnail

Mathematical Modeling with MATLAB Products - webinar demo files

by

 

Demo files from March 10, 2011 webinar titled 'Mathematical Modeling with MATLAB Products'

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

%  Auto-generated by MATLAB on 08-Mar-2011 12:24:52
%  Copyright 2011 The MathWorks, Inc.

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

if ~isempty(strings) && ~isempty(numbers)
    [strRows, strCols] = size(strings);
    [numRows, numCols] = size(numbers);
    likelyRow = size(raw,1) - numRows;
    % Break the data up into a new structure with one field per column.
    if strCols == numCols && likelyRow > 0 && strRows >= likelyRow
        newData1.colheaders = strings(likelyRow, :);
    end
end

% Create new variables in the base workspace from those fields.
for i = 1:size(newData1.colheaders, 2)
    assignin('base', genvarname(newData1.colheaders{i}), newData1.data(:,i));
end

Contact us