Plot using combined data from multiple excel columns

14 visualizaciones (últimos 30 días)
Yu Lu
Yu Lu el 9 de Jul. de 2017
Respondida: dpb el 9 de Jul. de 2017
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 comentarios
KSSV
KSSV el 9 de Jul. de 2017
You need to read the data from excel using xlsread and concatenate the columns as you required.
Yu Lu
Yu Lu el 9 de Jul. de 2017
Editada: dpb el 9 de Jul. de 2017
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.

Iniciar sesión para comentar.

Respuestas (1)

dpb
dpb el 9 de Jul. de 2017
_"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.

Community Treasure Hunt

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

Start Hunting!

Translated by