Text-only Table of Contents (frame/ no frame)
(15) Importing Data into Matlab Previous Top Next

Importing Data Into Matlab


try:
help iofun
help fileformats
uiimport
mydata=importdata('Sample_Data_File.txt')
textscan_example


% textscan_example.m - example of using textscan command to import data
fid=fopen('Sample_Data_File.txt');
numCols=10;
numHeaders=1;
format1=repmat('%s ',1,numCols);
format2=repmat('%d ',1,numCols-1);
format2=['%s ' format2];
myHeader=textscan(fid,format1,1);
myData=textscan(fid,format2);
fclose(fid);
disp('here are the first 5 elements from column 1 (not including the header row');
myData{1,1}(1:5)
disp('here are the 10 elements from column 9 (not including the header row');
myData{1,9}(1:10)
disp('here are the first 8 columns in the header row');
myHeader{1,1:8}







Previous Top Next


Importing_Data.src  last modified Oct 17, 2007 Introduction Table of Contents
(frame/no frame)
Printable
(single file)
© Dartmouth College