1

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!

4

2 回答 2

2

对于您的第一个问题,您可以使用cell array符号来格式化您的消息框文本:

rVal = 25;
gVal = 35;
bVal = 45;
msg = {['Red   ',num2str(rVal)];...
       ['Green ',num2str(gVal)];...
       ['Blue  ',num2str(bVal)]};

这允许您垂直连接多长度字符串。

如果您的输出是 Nx1 列向量,您始终可以使用以下方式对其进行格式化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);

只要您将 msgTxt 大小与输出大小相匹配,这对于任何大小的输出变量都应该可以正常工作。

至于让您的程序等待用户响应,请尝试uiwait

mH = msgbox(msg);
uiwait(mH)
disp('Let''s continue...')
于 2013-08-06T13:39:52.237 回答
0

msgbox 可以这样格式化

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

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

在你问题的后面部分之后

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');
于 2013-08-06T13:29:49.557 回答