Blank Space that isn't a Blank space

조회 수: 11 (최근 30일)
Brendan
Brendan 2012년 8월 8일
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.

채택된 답변

Honglei Chen
Honglei Chen 2012년 8월 8일
편집: Honglei Chen 2012년 8월 8일
Does deblank work for you? At least worth a try.

추가 답변 (1개)

Brendan
Brendan 2012년 8월 8일
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
Walter Roberson
Walter Roberson 2012년 8월 9일
what did x(8)+0 report?
Honglei Chen
Honglei Chen 2012년 8월 9일
strtrim only deals with white spaces while deblank also takes care of null spaces.

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

카테고리

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