How do I extract specific rows from Excel and transfer those into Matlab?

33 views (last 30 days)
Chase Dierkers
Chase Dierkers on 14 Jul 2020
Answered: benvolio on 14 Jul 2020
Hello
I am working on a project for school and I am completely lost. The goal is to extract certain rows of data from a large Excel file full of data that has already been given restraints. For example, my teacher has given us the code to import this data from Excel into Matlab, which is something that I have already done. For the project, however, I am working with 3 others and our data is split amongst the four of us. I need to find a way to set aside the large Excel file and create a code that will only show my specific data set that I am working with.
For my project I am in charge of the data under the HIC or Numeric Economic Status #1. I thought that I could limit the data by inserting this code:
HIC1_Data=xlsread('Plastic Waste Inputs Data.xlsx','C<2:P193');
By doing this, I thought that I could get all of the data in column C that was less than 2, which could only be 1, which is the data set that I am in charge of. With that in mind, MATLAB is saying that this range is invalid.
Is there any way to limit the rows so that I can only show rows that have a 1 in the C column? Or am I going about this the wrong way?

Answers (1)

benvolio
benvolio on 14 Jul 2020
Try the readmatrix function. Something along the lines of
column_C = readmatrix(path2xlsx, 'Range', 'C:C');
% To get the rows that have a '1' in the C column
rows_with1 = column_C(column_C < 2)
% rows_with1 now has values of column C with 1 as a value

Tags

Products

Community Treasure Hunt

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

Start Hunting!