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

1 Ansicht (letzte 30 Tage)
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!!

Akzeptierte Antwort

Guillaume
Guillaume am 30 Jan. 2019
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 Kommentare
Stelios Fanourakis
Stelios Fanourakis am 30 Jan. 2019
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 am 30 Jan. 2019
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)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by