문제

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!

도움이 되었습니까?

해결책

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

다른 팁

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');
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top