Error in appdesigner number of arguments

5 ビュー (過去 30 日間)
Miguel A.
Miguel A. 2025 年 5 月 13 日
編集済み: Miguel A. 2025 年 5 月 14 日
MATLAB version: 2022b.
When creating a simple app with just one single push button, and assigning a callback MATLAB automatically creates a function for the pushbutton:
function ButtonPushed(app, event)
But later, in the properties of the pushbutton, it creates thre arguments for the callback function:
app.Button.ButtonPushedFcn = createCallbackFcn(app, @ButtonPushed, true);
If I try to run this app, I get continuously the error:
Error using uibutton
Incorrect number of input arguments.
Error in temp1 (line 46)
createComponents(app)
How can I avoid that inconsitency? MATLAB does it automatically for me and I cannot change it because it is not in the editable area.
I have attached a screenshot.
Can someone please help me out?

採用された回答

Matt J
Matt J 2025 年 5 月 13 日
編集済み: Matt J 2025 年 5 月 13 日
There's nothing wrong with the code. I suspect you have defined your own version of uibutton() somewhere shadowing the builtin function? Execute the following and report the output to us,
which -all uibutton
  3 件のコメント
Stephen23
Stephen23 2025 年 5 月 14 日
"May be there is nothing wrong with the code, but MATLAB is unable to run such a simple application."
Because you have created a file named UIBUTTON which shadows the inbuilt function.
"It produces the same error each time: a difference in the number of arguments for the Pushbutton."
Because you have created a file named UIBUTTON which shadows the inbuilt function.
"This is the output of that command"
U:\Folder\matlab\scripts\uibutton\uibutton.m % !!!!!!!! DELETE or RENAME !!!!!!!!!!!
Miguel A.
Miguel A. 2025 年 5 月 14 日
編集済み: Miguel A. 2025 年 5 月 14 日
Thank you so much. Problem is solved. Issue seems to have raised when ICT related migration of user profiles internally at my institution took place and I had to redefine again my path.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by