MATLAB: Strtrim not working for cell array

cellerrorstrtrim

I have a cell of 472*12 size. I am trying to use strtrim on this cell but I am getting an error which says "Input should be a string or a cell array of strings." Can anyone help me with this?

Best Answer

[] is not of type char so you are current attempting to use strtrim on non-strings.
Here is a workaround:
new_tableData = cellfun(@(S) strtrim([S '']), tableData, 'Uniform', 0);
The [] of '' has no effect on strings, but has the subtle side effect of converting [] into '' which can be trimmed.