MATLAB: I have 2 columns and 10 rows of numerical data in the excel file. How to import this data in to MATLAB and then plot it

excelimport

0 2.49939
2.00E-04 -1.28174
4.00E-04 3.05481
6.00E-04 0.790405
8.00E-04 -0.448608
1.00E-03 2.28577
1.20E-03 1.11084
1.40E-03 8.54E-02
1.60E-03 2.30713
1.80E-03 1.77307
2.00E-03 -0.83313
2.20E-03 3.22571
2.40E-03 1.34583
2.60E-03 0.27771
2.80E-03 1.19629
3.00E-03 0.341797
3.20E-03 1.36719
3.40E-03 1.96533
3.60E-03 0.448608
3.80E-03 3.26843
4.00E-03 0.683594
4.20E-03 -1.83716
4.40E-03 4.14429
For example, I have this kind of numerical data with 2 column and 10 rows in my excel file. How to import the Excel file to MATLAB? I need the data to plot the graph.

Best Answer

Importing data from Excel can be done using the “readtable” function.
For example, to read all data from myfile.xls:
T = readtable('myfile.xls')
Or read only a specific range from a specific sheet using:
T = readtable('myfile.xls', 'Sheet',1, 'Range','A1:B10')
Plot the data from the table using a visualization function. For example, use “scatter”:
X = T.Var1; % First column of data
Y = T.Var2; % Second column of data
scatter(X,Y);
For more information, see: