Why is it in matlab, that when you type a statement such as
percentage =22
strcat('Transfer is ', num2str(percentage), '% complete');
The result removes the whitespace prior to the numstr() operator… i.e
ans = 'Transfer is23% complete'
Is there a way to prevent it from stealing my whitespace?
This is because
strcatremoves the whitespace. According todoc strcat:For character array inputs, strcat removes trailing ASCII white-space characters: space, tab, vertical tab, newline, carriage return, and form-feed.Solutions:
1) You may try
sprintf('Transfer is %d%% complete', percentage);2) Use
['Transfer is ', num2str(percentage), '% complete']rather thanstrcatfor string concatenation.