How to select some specific rows from excel

8 Ansichten (letzte 30 Tage)
yang
yang am 7 Aug. 2018
Kommentiert: GAGANDEEP KAUR am 10 Dez. 2020
I have a problem to select specific rows meeting criterion from excel.
The third column in my data is the criterion. I want to select the rows whose third column numbers are in a certain range, and then keep the whole row and create a new excel file for it.
I mainly have three questions:
a. In what format should I input my data? Should I use xlsread or input it as a table?
b. Which type of data is more convenient for selection and output as excel? Double, string, cell?
c. What function should I use to select certain rows?
Thank you if anyone could help me.

Akzeptierte Antwort

Savio Tran
Savio Tran am 7 Aug. 2018
Using xlsread, you can pull in the row you wanted as follows:
filename = 'dummy.xls';
data = xlsread(filename); %import data
columnData = data(:,3); %pull out column
This should pull your data out as an array of doubles, and then you can select rows using comparisons to filter
inRangeIndexes = find(columnData<lowerRange & columnData>upperRange);
newDataSet = data(inRangeIndexes,:); % contains only desired rows
Then, you can export your new data set using xlswrite.
  2 Kommentare
yang
yang am 8 Aug. 2018
Thank you so much!!
GAGANDEEP KAUR
GAGANDEEP KAUR am 10 Dez. 2020
Can any one please tell how can I transpose data containing range in MATLAB as if
x1=x((1:3),1);
x2=x((1:3),2);
I need x1 and x2 as transpose of x with specified rows and columns(data selected from excel sheet)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by