Plot using combined data from multiple excel columns

조회 수: 12 (최근 30일)
Yu Lu
Yu Lu 2017년 7월 9일
답변: dpb 2017년 7월 9일
Hi
What should I do if I want to plot using combined data from multiple excel columns? For example x data are from B1:B5 plus C4:C8 then y data from E4:E8 plus F2:F6
And the expecting result graph is reflecting a single set of x-y data.
I know how to plot if the data on excel spreadsheet are together and in the same column or row (expressed by only one'something:something')
Many thanks.
  댓글 수: 2
KSSV
KSSV 2017년 7월 9일
You need to read the data from excel using xlsread and concatenate the columns as you required.
Yu Lu
Yu Lu 2017년 7월 9일
편집: dpb 2017년 7월 9일
Hi Yes I know that bit such as:
filename='AAA.xlsx';
x1=xlsread(filename,'sheet1','J4:J13');
y1=xlsread(filename,'sheet1','E4:E13');
then
p=plot(x1,y1,'k d');
However what should I do to use data J4:J13 PLUS A1:A4 together as my x values? Thanks.

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

답변 (1개)

dpb
dpb 2017년 7월 9일
_"B1:B5 plus C4:C8 then y data from E4:E8 plus F2:F6"_
The brute-force way...
xdata=xlsread('YourXLSFile.xls',1,'B1:C8'); % return all the data contain x
ydata=xlsread('YourXLSFile.xls',1,'E4:F8'); % return all the data contain y
x=[xdata(1:5,1); xdata(4:8,2)]; % the two sections of xdata
y=[ydata(1:5,1); ydata(2:6,2)]; % the two sections of ydata
hL=plot(x,y); % plot resultant vectors
Generalize the logic by using variables for the various row/column boundary points and then compute the address locations from them if this is needing to be done for more than just the one specific case.
But, the idea is generic; you just have to know where the locations of interest are and select the proper subsets of input array(s) and concatenate to build the full vectors.

카테고리

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