It is not difficult. I've listed a couple of methods to do it. The first uses a for loop, as suggested by misterT. The second (or third) uses strrep to replace parts of the halt string). This means that you only need to use a single method in each code block to get the described output. Using all lines in a code block will get a duplicated output.
For inserting a space between occurrences of A & B (which seems to be what you asked for):
Code:
>> for i=1:length(halt)-1, if halt(i)=='A' && halt(i+1)=='B', fprintf('A '); else fprintf('%c', halt(i)); end; end; fprintf('%c\n', halt(end));
>> disp(strrep(halt,'AB','A B'))
Output: A BAAAA BBAA BA BAAA BAA B (repeated on two lines)
If you wanted spaces between A & B and B & A, then