String split from the line .

5 visualizaciones (últimos 30 días)
Karanvir singh Sohal
Karanvir singh Sohal el 5 de Abr. de 2021
Comentada: Karanvir singh Sohal el 5 de Abr. de 2021
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'}

Respuesta aceptada

Matt J
Matt J el 5 de Abr. de 2021
Editada: Matt J el 5 de Abr. de 2021
As an example,
B=split( ',A,B,C,D' , ',');
B=B(~cellfun('isempty',B))
B = 4×1 cell array
{'A'} {'B'} {'C'} {'D'}
  3 comentarios
Matt J
Matt J el 5 de Abr. de 2021
Add
B=B(~cellfun('isempty',B))
Karanvir singh Sohal
Karanvir singh Sohal el 5 de Abr. de 2021
Thanks @Matt J :)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by