String split from the line .

조회 수: 3 (최근 30일)
Karanvir singh Sohal
Karanvir singh Sohal 2021년 4월 5일
댓글: Karanvir singh Sohal 2021년 4월 5일
Hello!
I have strings stored in "myline" variable.
myline = ,A,B,C,D,E,F,G,H,I,J,K
I want to split the string at(,) and also wants to remove the empty space(" ",A) which is available before A.
Further I want to store these in variable "B".
B={'A';'B';'C';'D';'E';'F';'G';'H';'I''J';'K'}

채택된 답변

Matt J
Matt J 2021년 4월 5일
편집: Matt J 2021년 4월 5일
As an example,
B=split( ',A,B,C,D' , ',');
B=B(~cellfun('isempty',B))
B = 4×1 cell array
{'A'} {'B'} {'C'} {'D'}
  댓글 수: 3
Matt J
Matt J 2021년 4월 5일
Add
B=B(~cellfun('isempty',B))
Karanvir singh Sohal
Karanvir singh Sohal 2021년 4월 5일
Thanks @Matt J :)

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

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