How to extract rows if column starts with a specific string?

조회 수: 10 (최근 30일)
Lee
Lee 2018년 8월 18일
댓글: Walter Roberson 2018년 8월 18일
I have a data table that contains columns like this:
SampleName = {'13C3099';'13C3045';'14C3092';'14C3013'};
pH = [5.3822;4.382;4.9873;6.001];
Data = table(SampleName,pH)
I am trying to extract all the rows that have a sample name that starts with "13C". I have tried:
ExtractedRows = Data(:,Data.SampleName == '13C')
But I get the error "Undefined operator '==' for input arguments of type 'cell'." Can anyone help me identify what I am doing wrong?

채택된 답변

Walter Roberson
Walter Roberson 2018년 8월 18일
ExtractedRows = Data( startsWith(Data.SampleName,'13C'), : );

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by