您可以将strtrim()与structfun()和单元索引结合使用:
your_struct = structfun(@(x) strtrim(x{1}), your_struct);
这仅适用于您的结构具有类似布局的情况
your_struct.a = {' some string '};
your_struct.b = {' some other string '};
...
如果它有不同的结构,比方说,
your_struct.a = { {' some string '}
{' some other string '}};
your_struct.b = { {' again, some string '}
{' again, some other string '}};
...
你可以试试
your_struct = structfun(@(x) ...
cellfun(@strtrim, x, 'uni', false), ...
your_struct, 'uni', false);