MATLAB: Split legend after blank space

MATLAB

I know this has been discussed several times before, but I still cannot figure it out. I have a 4×1 cell with stings I want to use as plot legends, and it is working fine. The first 3 strings comes from a checkbox selection and string 4 comes from averaging plot 1-3.
Title = {
'123456789_1'
'ABCDEFGHIJ_1'
'123ABC_1'
'Av. (123456789_1 ABCDEFGHIJ_1 123ABC_1)'
}
Is it possible to devide string no 4 into multiple lines with a linebreak after each blank space so that string number 4 would be:
Av.
(123456789_1
ABCDEFGHIJ_1
123ABC_1)

Best Answer

Just use strrep to replace the spaces by a linefeed (char(10)):
legend(strrep(Title, ' ', char(10)));
Related Question