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

조회 수: 22 (최근 30일)
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.

채택된 답변

Martijn
Martijn 2011년 2월 2일
편집: MathWorks Support Team 2018년 11월 8일
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:
  댓글 수: 3
Image Analyst
Image Analyst 2013년 11월 3일
The file is not there. Correct the filename, or else find the file and put it in that folder.

댓글을 달려면 로그인하십시오.

추가 답변 (4개)

Davide Ferraro
Davide Ferraro 2011년 2월 2일
편집: John Kelly 2015년 2월 26일
If you prefer to use an interactive approach you can double click on the Excel file from the Current Folder browser and interactively import the data. As soon as the data is in your workspace you can use PlotTools to quickly create and customize your plot.
The Import Wizard GUI is presented on page:

Chetan Rawal
Chetan Rawal 2015년 9월 10일
There are newer ways to do this using Tables. See this link for all options of using MATLAB with Excel:

bayran arrieta
bayran arrieta 2016년 9월 15일
X=xlsread('file.xls');

woldie kassie
woldie kassie 2017년 3월 28일
편집: woldie kassie 2017년 3월 28일
if the excel data file contains look like this
Day Spinning Weaving Finishing Garment output1
1 3830.6 12577.7 0 3942.7 78766 65868
2 3013.3 11035.3 0 0 78773 65873
3 3655.3 9821 0 3069 78780 65878
4 5936.7 12126 0 3365.3 78786 65883
5 3852.5 14302.3 0 3639 78793 65888
6 5640 14333.8 39343.9 1004.1 788800 65893
7 6386.4 14622.2 44093.96 4108 0 0
8 6990.9 14389.1 44854.1 4493.36 78813 65902
9 6448.3 14087.4 0 3679 78820 65907
10 5428.7 15500 0 8258 78826 65912
11 5463.8 16029.9 61814.64 7309 78833 65916
12 6172.6 16152 48760.44 5354.4 78846 65921
13 6669.4 17066.5 54245.9 4537 0 0
14 6612.6 16067 60566.6 3982 78859 65926
15 7273.3 15764 47332.84 1834 78867 65935
16 5666.5 14364 0 0 78874 65940
17 6427 15603 0 2514 78881 65945
18 6832.5 17314 38463 5561 78888 65950
19 6936.1 17858 40385.5 4090 78895 65955
20 6789.4 17788 30935.37 5748 0 0
21 7077.1 17485 44668.53 4132 78981 65960
22 7318.4 16639 63828.8 4138 78995 65965
23 7302.4 15000 42787.42 0 78921 65974
24 7418.5 17242 48211.74 4663 78927 65978
25 7946.4 16113 56758.1 6430 78935 65982
26 7864.5 14249 24724.14 6983 78940 65988
27 7880.9 16250 29700.24 4800 0 65993
[v,T,vT]=xlsread('Book1.xlsx') ;
cla;
hold on;
title('Decision Boundary at Epoch Number ');
t=v(:,1);is the x-axis
y=v(:,2);
plot(t,y)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by