How to keep rows including a specific name in structure and remove everything else within the structure?

조회 수: 7 (최근 30일)
Hi all,
I have a shape file (shp) that is read as a structure within MATLAB. It is a 2540x1 struc in the worksapce. One of its columns is character type. chr. I want to find a few names in it like 'Malta', keep the entire row that includes the Malta and then remove all other rows. Could you please teach me how to do that?
  댓글 수: 1
Jan
Jan 2021년 3월 14일
Please post a short example of how your data look like. I do not understand "One of its columns is character type. chr." Structs do not have "columns".

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2021년 3월 14일
placenames = {YourStruct.PlaceNameField};
wanted_mask = ismember(placenames, {'Malta', 'Paraguey', 'Lake Wawa'});
selected_members = YourStruct(wanted_mask);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by