How to have a struct as input to an external function?

Hi,
I want to call an external function inside my matlab gui with the handles structure as input, as all my input parameters are inside that structure. However, when trying
myfct(handles)
Inside one of my callbacks in the gui m-file i receive a matlab error Undefined function 'myfct' for input arguments of type 'struct'.
I really don't know what Im doing wrong, especially because I have done similar earlier in my gui. Anyone who can help...

回答 (2 件)

Ryan Livingston
Ryan Livingston 2013 年 1 月 23 日

0 投票

Odds are MYFCT is not on the path when the GUI code is running so it cannot be located. If you replace that with a call to:
which myfct
it should again say it is not found. You can try
  1. Add MYFCT to the MATLAB path
  2. Define MYFCT as a subfunction in the GUI code
  3. Dynamically add the path to it in the GUI open callback and remove the path in the 'CloseRequestFcn' callback:

2 件のコメント

Christian
Christian 2013 年 1 月 23 日
Your right its not in the path, but i dont understand why matlab says so. The file (myfct.m) is in the exact same folder as my gui files (.m and .fig)...?
So how do i add the myfct to the matlab path??
Walter Roberson
Walter Roberson 2013 年 1 月 23 日
Perhaps the code changed directory at some point?

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

Christian
Christian 2013 年 1 月 23 日

0 投票

Okay, somehow this issue fixed itself. However, have no idea how. So could someone maybe tell me how to add a function to the matlab path...?

カテゴリ

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

製品

質問済み:

2013 年 1 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by