Sha256: 02e47d52adf1b539fdc8e766bf277f2e50b1dcef5ba2b0b01f424248b8b7cf53
Contents?: true
Size: 992 Bytes
Versions: 10
Compression:
Stored size: 992 Bytes
Contents
function import_csv(fileToRead1) %IMPORTFILE(FILETOREAD1) % Imports data from the specified file % FILETOREAD1: file to read % Auto-generated by MATLAB on 24-May-2010 11:01:12 if ~exist(fileToRead1) error('File %s does not exist.', fileToRead1) end % Import the file newData1 = importdata(fileToRead1); % Split Headers headers = regexp(newData1.textdata, ',', 'split'); % headers = headers{1} % If Matlab FAILED to read an empty vector, assign it. % if size(newData1.textdata, 2) ~= size(headers, 2) % newData1.data(:, size(headers,2)) = NaN % end % Create an array of NaN's of proper dimensions (as many rows as data and as many columns as header) and insert the data on top of it. data = zeros(size(newData1.data, 1), size(headers,2)) + nan; data(1:size(newData1.data,1),1:size(newData1.data,2)) = newData1.data; % Create new variables in the base workspace from those fields. for i = 1:size(headers, 2) assignin('caller', genvarname(headers{i}{1}), data(:,i)); end
Version data entries
10 entries across 10 versions & 1 rubygems