필터 지우기
필터 지우기

Strings: delete rows with empty values

조회 수: 34 (최근 30일)
Matthew Tyler Jeffries
Matthew Tyler Jeffries 2019년 2월 25일
댓글: Stephen23 2020년 7월 14일
I have a very large string array (part of it is shown below), and sometimes the secound column contains "empty" values. I would like to delete each row whose second column is empty.
"laterite-00047" "" "zeros(0,1)"
"laterite-00048" "" "zeros(0,1)"
"laterite-00049" "204186,54901" "204186"
"laterite-00050" "204186,54901" "54901"
"laterite-00051" "" "zeros(0,1)"
"laterite-00052" "204186,54901" "54901"
  댓글 수: 2
madhan ravi
madhan ravi 2019년 2월 25일
attach part of your string array as .mat file
Stephen23
Stephen23 2020년 7월 14일
For a string array the correct method to way to cound the number of characters is to use strlength:

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

채택된 답변

madhan ravi
madhan ravi 2019년 2월 25일
a(~any(cellfun('isempty',a),2),:) % where a is your string array
  댓글 수: 2
madhan ravi
madhan ravi 2019년 2월 25일
Alternative (faster):
a(~strcmp(a(:,2),""),:)
Aishwarya Venkatesh
Aishwarya Venkatesh 2020년 7월 14일
if i want to remove columns containing all empty values in the string. Then how this can be modified?

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

추가 답변 (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