Question

I want to show my output in a msgbox so I have used msgbox(num2str(output)) but I want to name each line, eg:

Red    25
Green  52
Yellow 88

but when I try to do that it says

Error using horzcat
     CAT arguments dimensions are not consistent.

And when that window pops up and the user press OK then another window will pop up asking

W = questdlg('Would you like to retrain or test the network?', ...
        'Artificial Neural Network', 'Retrain', 'Test', 'Exit', 'Exit');

So, how can format my msgbox and as soon as the OK button is pressed another window will popup?

Any help would be appreciated!

Thanks!

Was it helpful?

Solution

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...')

OTHER TIPS

msgbox can be formatted like this

R=23;G=35;B=45; %given values

    (msgbox({['Red ',num2str(R)];['Green ',num2str(G)];['Blue ',num2str(B)]; }));

After your later part of the question

uiwait(msgbox({['Red ',num2str(R)];['Green ',num2str(G)];['Blue ',num2str(B)]; }));

W = questdlg('Would you like to retrain or test the network?', ...
        'Artificial Neural Network', 'Retrain', 'Test', 'Exit', 'Exit');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top