Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

how to do it...

2 views (last 30 days)
Rizwana
Rizwana on 6 Nov 2013
Closed: MATLAB Answer Bot on 20 Aug 2021
I have an excel sheet.. it reads huge data eg: 1647 *20. I used load function to extract 1st & 5th column. But still i wann some function to restict it so that it reads the data from the corresponding column upto 10/certain limit but not all... Like 1 column is time: showing time from 1 till 162 secs.. similarly 5 th column showing pressure from some random data... I want to read 1st 10 time & 1st ten pressure data from my excel sheet.

Answers (3)

Image Analyst
Image Analyst on 6 Nov 2013
That is not huge - far, far from it. You can pass in the range you want to read into xlsread(), so just pass in a smaller range. If you don't know the range until you've read it in, then read in a little bit more than you think you'd need and check. Otherwise you can use ActiveX to pull over one cell at a time and check it, but honestly I don't believe that will give you any noticeable speed up over just reading the whole thing in and checking it in MATLAB. Or you could read in the whole time column, then check it to see how many rows you need, then read in that many rows from column 5. If you did that, you should use ActiveX because it you used xlsread() to do that, it involves launching Excel twice and shutting it down twice, which is time consuming.
If you're interested, I've attached an ActiveX demo below.

Image Analyst
Image Analyst on 6 Nov 2013

David Sanchez
David Sanchez on 6 Nov 2013
Option 1:
my_data_time = xlsread('your_excell.xls','A1:A10'); % first column
my_data_pressure = xlsread('your_excell.xls','E1:E10'); % fifth column
Option 2:
all_data = xlsread('your_excell.xls');
my_data = all_data(1:10,[1,5]);
% you'll end up with a matrix whose first column is time and second column is pressure
  2 Comments
Rizwana
Rizwana on 7 Nov 2013
Thank you. But what should i do when i have just data with no headers like A or B or C.. Should i manually type it in my excel.
ES
ES on 7 Nov 2013
Those are not headers.. 'A1:A10' is a cell range of 10 cells starting A1 to A10.
my_data_time = xlsread('your_excell.xls','A1:A10'); % first column
this particular line will read first 10 rows of the first column of your excel file. Excel file has this row information with it. These are not any typed headers or so.

This question is closed.

Tags

Community Treasure Hunt

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

Start Hunting!