MATLAB: How to put spaces between the elements inside a char array

MATLABspacesxlsread

Hello, gyus 🙂
Let's say I have a char array like:
data = [ format_time, ' ', format_data, ' ', '\r\n'];
where
format time = %4d %4d %2d
( There are spaces between the formats)
and
format_data = %6.3f%6.3f%6.3f%6.3f%6.3f%6.3f%6.3f%6.3f
( there are not spaces)
and the output is something like : %4d %4d %2d %6.3f%6.3f%6.3f%6.3f%6.3f%6.3f%6.3f%6.3f
The data from format_data are stored by using xlsread function from excel,
otherwise my outputs are joined

Best Answer

Try this below it might help:
format_data = '%6.3f%6.3f%6.3f%6.3f%6.3f%6.3f%6.3f%6.3f';
format_data = strrep(format_data,'%',' %');
format_data(1) = '';