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

1 回表示 (過去 30 日間)
Stelios Fanourakis
Stelios Fanourakis 2019 年 1 月 30 日
コメント済み: Guillaume 2019 年 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 件)

Community Treasure Hunt

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

Start Hunting!

Translated by