How to read excel data include specific word? cell?
Show older comments
Hi, all
[~,~,data] = xlsread('kpmarch.xlsx' );
data=[data(:,1) data(:,3) data(:,4) ];
There's 6columns in my excel file and I took A,C,D 3colomns form excel
next step, i only wanna take rows which include 'Planetary' in column C(OBSRVT_NM)
How can i do this..
Accepted Answer
More Answers (1)
Walter Roberson
on 2 Aug 2022
It is not possible to read rows selectively, other than by consecutive position.
You will need to do something such as
mask = ismember(data(:,3), 'Planetary');
subset = data(mask, [1 4]);
Note: we recommend that you switch to readtable()
data = readtable('kpmarch.xlsx');
mask = ismember(data.OBSRVT_NM, 'Planetary');
subset = data(mask, [1 4]);
Then subset{:,2} would be datetime objects.
Your xlsx file is odd: all of your numbers are represented as text.
1 Comment
Nicolas Alfred
on 2 Aug 2022
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!