フィルターのクリア

Chars with white space

2 ビュー (過去 30 日間)
Lucas
Lucas 2012 年 6 月 25 日
Using xmlread() I found that MatLab adds a lot of white space into the project for whatever reason. But I get values when I read some node of a cell array with a char in it with the value of ' '. The value varies with blank characters. When I read my xml file out it looks like:
Test
TestVar
boolean
32
So when I try to populate my struct I get a lot of blank values added in. I tried to use isempty() but since the cell array has a value of a char 1x4 of blank characters it thinks something in there. Is there something I can use to check is a char has characters present in it? That way I can skip the write to my struct?

採用された回答

Jan
Jan 2012 年 6 月 25 日
a = deblank(a);
a(cellfun('isempty', a)) = [];

その他の回答 (1 件)

Honglei Chen
Honglei Chen 2012 年 6 月 25 日
  1 件のコメント
Honglei Chen
Honglei Chen 2012 年 6 月 25 日
Hi Lucas, I could be wrong, but after you use deblank, you should be able to remove empty cells
a = {'Test',' '}
a = cellfun(@deblank,a,'UniformOutput',false)
a(~isempty(a))
Note that in the original definition of a, you can put in multiple spaces. Somehow it does not show multiple spaces in comment.

サインインしてコメントする。

カテゴリ

Help Center および File Exchange3-D Function Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by