Plot using combined data from multiple excel columns
14 views (last 30 days)
Show older comments
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 Comments
KSSV
on 9 Jul 2017
You need to read the data from excel using xlsread and concatenate the columns as you required.
Answers (1)
dpb
on 9 Jul 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.
0 Comments
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!