Undefined variable when executing new object

Hello, I got an error when my function its trying to open a new object (window).
This is the code:
function SelectFiles
%SelectFiles is a function that open last records
%
status = system('C:\BinaryFilesMatlab\SaveBinaryMatFile.exe 2 C:\Users\Kaf-125\Desktop\Versions\actual_gui3_patch2\file_name.mat m0_def_f0_fk');
if status == 0
load('file_name.mat');
res_opt = Results_with_opt(hObject,eventdata);
else
error('Error al sustituir el archivo');
end
end
This is the error:
Undefined function or variable 'hObject'.
Error in SelectFiles (line 8)
res_opt = Results_with_opt(hObject,eventdata);
Thank you in advance.

3 件のコメント

Stephen23
Stephen23 2018 年 8 月 16 日
編集済み: Stephen23 2018 年 8 月 16 日
Your code calls Results_with_opt with two input arguments:
Results_with_opt(hObject,eventdata);
Neither of those input arguments are define in your code. What do you expect them to be?
Adam
Adam 2018 年 8 月 16 日
What are you expecting hObject to be? Your function takes no input arguments and hObject is not defined inside the function.
Functions have closed scope - only variables passed in or defined in the workspace are visible within the function.
I am guessing that this is code in a GUI somewhere. If it is in a callback then you should have hObject as an input argument.
Oscar Espinosa
Oscar Espinosa 2018 年 8 月 16 日
I solved it, just needed to call the function without arguments. Thank you.

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

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeFunction Creation についてさらに検索

タグ

質問済み:

2018 年 8 月 16 日

コメント済み:

2018 年 8 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by