Blank Space that isn't a Blank space

10 visualizaciones (últimos 30 días)
Brendan
Brendan el 8 de Ag. de 2012
Hi all,
I have a strange thing happening with a string. I am reading in a string from a binary file and it puts a blank space at the end of the string. For example, the string would read x='1234567 '. Im trying to remove that last space. I have tried strtrim and x(x~=' ') and regexprep but can remove this space. The problem is probably because strcmp(x(8),' ') returns 0 so this space is somehow not equal to a blank space. If anyone has ever seen this any help would be greatly appreciated.
Thanks
Brendan
PS. I can't just cut off the last space because I don't know if it will always be there so I need to test to make sure its blank.

Respuesta aceptada

Honglei Chen
Honglei Chen el 8 de Ag. de 2012
Editada: Honglei Chen el 8 de Ag. de 2012
Does deblank work for you? At least worth a try.

Más respuestas (1)

Brendan
Brendan el 8 de Ag. de 2012
Thanks a bunch. This worked. Its strange that strtrim didn't and this did. But I guess you only need one thing that works
  2 comentarios
Walter Roberson
Walter Roberson el 9 de Ag. de 2012
what did x(8)+0 report?
Honglei Chen
Honglei Chen el 9 de Ag. de 2012
strtrim only deals with white spaces while deblank also takes care of null spaces.

Iniciar sesión para comentar.

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