How to Read MATLAB
MATLAB, produced by MathWorks, is a software package for technical data acquisition, analysis, modeling and graphing. Functions provided by MATLAB allow you to import data from a wide variety of raw, image, spreadsheet and other formats. MATLAB also provides low-level file I/O functions that allow you to read and format data from arbitrary file types.
Instructions
-
-
1
Execute the uiimport() function to open a file selection window. After selecting a file, MATLAB will attempt to guess the file format and read formatted data into a MATLAB matrix. The default name of the workspace variable is the name of the file.
-
2
Execute the importdata() function to load data if you know a file name or have it stored in a string. The importdata() function will call the associated function based on the file extension.
my_data = importdata('my_spreadsheet.xls"'; %Opens using xlsread()
my_data = importdata('my_ascii_file.dat','\t',5); %Opens a tab-delimited ASCII file with 5 header lines -
-
3
Call the file-specific import function directly to open the many file types that MATLAB recognizes. This will also allow you to specify additional options for importing non-standard format files.
my_data = xlsread('my_spreadsheet.xls',2); %read from spreadsheet 2
my_image = imread('my_image.tif'); -
4
Open binary data files using the low-level file I/O functions fopen() and fread().
my_file_handle = fopen('my_binary_file.dat','rb');
my_data = fread(my_file_handle,n_datapoints,'single'); %read n single-precision floating point numbers
fclose(my_file_handle);
-
1
References
- Photo Credit Ablestock.com/AbleStock.com/Getty Images