Importing Data in MATLAB Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report MATLAB provides a simple way of importing data into a script using the importdata() function. This function takes various inputs and can be used in following forms. Method 1:This simply takes the data file and creates a suitable struct for the same within the script. Example 1: Matlab % MATLAB Code for import data a = importdata('logo.jpg'); % Verifying the data image(a) Output: This would first load the logo.jpg file as a struct and then, the second statement would display that data as an image to verify the data. Method 2:Now let us import a file with delimiters and headers. Our data file has the following dummy data with headers and delimiter ' '. col1 col2 col3 10.1 12.3 13.7 14.2 13.6 11.9 0.13 1.13 13.1Example 2: Matlab % Importing this into MATLAB script % delimiter delimiterIn = ' '; % of header lines headerlinesIn = 1; % Importing the data a = importdata('data.txt',delimiterIn, headerlinesIn); % Display the data with headers disp(a.colheaders) disp(a.data(:,:)) Output: Method 3:Another method of using the importdata() function is when you do not know the delimiter in the data file. MATLAB does the job for you by determining the delimiter and saving it as a variable for you. See the following snippet. Data File: 10.1 12.3 13.7 14.2 13.6 11.9 0.13 1.13 13.1Example 3: Matlab % MATLAB Code for import data [a, delimiterOut] = importdata('data.txt') Output: This would store the data in a and the found delimiter in the delimiterOut variable. Comment More infoAdvertise with us Next Article Importing Data in MATLAB O owl0223 Follow Improve Article Tags : Software Engineering MATLAB-programs Similar Reads Importing Data in R Script We can read external datasets and operate with them in our R environment by importing data into an R script. R offers a number of functions for importing data from various file formats. In this article, we are going to see how to Import data in R Programming Language. Importing Data in R First, let' 3 min read Factorial in MATLAB MATLAB is a high-performance language that is used for matrix manipulation, performing technical computations, graph plottings, etc. It stands for Matrix Laboratory. In this article, we'll be calculating the factorial of a number n using MATLAB's built-in function 'factorial(number)'. Factorial:The 1 min read Curve Fitting in MATLAB Curve fitting is the method of finding a suitable equation for a given data or one could say finding a pattern in some random data. The goal of this article is to learn curve fitting using MATLAB thus, it is expected that the reader has knowledge of curve fitting in mathematical terms. Step of Curv 2 min read How to import data into SAS? Entering Data Directly: You can enter numbers of lines of data directly in SAS program by using a DATALINES statement. The keywords are as follows: DATA: The DATA step always starts with a DATA statement. The purpose of the DATA statement is to tell SAS that you are creating a new data set i.e. outd 3 min read Text Formatting in MATLAB In the real-world data can be any form. This data may be in binary, numeric, text, array, and so on. And this data can be converted into text. In Matlab, the text can be formatted using a formatting operator along with formatting functions such as sprintf, numstr, fprintf, compose. These functions/o 4 min read 2D Line Plot in MATLAB '2D' stands for 2-dimensional and a 2D line is a line that is moved in 2-dimensions. A line in 2D means that we could move in forward and backward direction but also in any direction like left, right, up, down. In MATLAB we have a function named plot() which allows us to plot a line in 2 directions. 4 min read Installing MATLAB on Linux MATLAB is a proprietary multi-paradigm programming language and numeric computing environment developed by MathWorks. MATLAB allows matrix manipulations, plotting of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with programs written in other language 3 min read App Building Components in MATLAB MATLAB provides an easy-to-implement solution for your ideas. You can represent your ideas in a GUI-friendly way using the MATLAB App Builder. Matlab app builder is very simple to use, which consisted of two parts, i.e., designing and coding part. The best part of Matlab App Builder is its ready-to- 6 min read Normalize Data in MATLAB Data Normalization is a technique in statistical mathematics that converts the entire data into a specified range or scale or normalizes it using different methods such as by computing its z-score. There is no specific definition of normalization but, it has various meanings depending on the user's 2 min read Cell Arrays in MATLAB In MATLAB, cell arrays are a type of arrays which stores elements of different data types and sizes in different cells, or one could say that cell arrays allow users to store heterogeneous data into a single array. For example, let us create a cell array which holds the name and age of a person. Exa 2 min read Like