Why I get this error of matrices not consistent? What's wrong?

1 次查看(过去 30 天)
I am trying to use that code
message = ({'Welcome, XXXXXXX';'I hope to Enjoy it' ; 'Please, share it' ; 'Cheers!'});
myicon = imread('maer.jpg');
waitfor(msgbox(message,myicon));
But I get the error
Dimensions of matrices being concatenated are not consistent.
Error in msgbox (line 182)
MsgboxTag = ['Msgbox_', TitleString];
Error in ruller (line 3)
waitfor(msgbox(message,myicon));
What matrices need to be same dimensions? The message and the image?
Following the guidelines here
Seems so easy. Please help!!

采纳的回答

Guillaume
Guillaume 2019-1-30
The icon is the 3rd input of msgbox, not the second. In fact, if you want to specify a custom icon, you've used the completely wrong syntax
I agree that the error is rather obscure, it would be better if msgbox checked that the 2nd input was valid. msgbox was expecting a one row input as the 2nd argument.
To specify a custom icon:
msgbox(message, 'some title', 'custom', myicon)
  6 个评论
Stelios Fanourakis
Stelios Fanourakis 2019-1-30
Neither of those lines actually work
hfig.Children(2).myicon = hfig.Children(2).myicon *2;
hfig.Children(3).message = hfig.Children(3).message *2;
Guillaume
Guillaume 2019-1-30
Why should they? I never suggested that.
As I said, it's probably simpler to build a GUI from scratch that is already as you want rather than resizing an existing figure and all the children.
As I said, hfig.Children(2) should be an axes. axes don't have a myicon property. The icon is the Children of that axes (so hfig.Children(2).Children). This will be an Image object. Multiplying an Image is meaningless. You would have to resize it and change its position. Possibly alter the CDataMapping property as well.
Similarly for the Text object (hfig.Children(3).Children), you'll have to change the position and FontSize property as well.
You may find it easier to find out which properties to edit in the figure hierarchy using the property editor. To get the property editor:
propertyeditor(hfig)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by