For your first question, you can use cell array
notation to format your message box text:
rVal = 25;
gVal = 35;
bVal = 45;
msg = {['Red ',num2str(rVal)];...
['Green ',num2str(gVal)];...
['Blue ',num2str(bVal)]};
This allows you to vertically concatenate multi-length strings.
If your output is an Nx1 column vector, you can always format it in this manner using cellfun
:
output = [25;35;45];
msgTxt = {['Red '];['Green '];['Blue ']};
msgNum = cellfun(@num2str,num2cell(output),'UniformOutput',false);
msg = cellfun(@(x,y) [x,y],msgTxt,msgNum,'UniformOutput',false);
As long as you match the msgTxt size with the output size, this should work fine for any size of the output variable.
As for making your program wait on the user response, try uiwait
:
mH = msgbox(msg);
uiwait(mH)
disp('Let''s continue...')