フィルターのクリア

How to import functions from a file to another?

31 ビュー (過去 30 日間)
Zineb EL MORCHID
Zineb EL MORCHID 2016 年 3 月 13 日
コメント済み: Zineb EL MORCHID 2016 年 3 月 13 日
I have two files , (f1.m) one has functions , and the other one represents the code of a GUI (f2.m). I want to use these functions of f1 in f2. I tried (addpath) but it doesnt work I got ( Warning: Directory access failure matlab ). So I changed the access rights and still not working . What am I missing ? How can I import functions from a file to another file?

採用された回答

Walter Roberson
Walter Roberson 2016 年 3 月 13 日
Only the first function in a file, the one with the same name as the file, can be directly referred to by another file; that second file just needs to refer to the first one by name when the first one is on the path.
Any other functions in a file can only be referenced by way of a function handle somehow provided by the first function in a file. For example, the first function could return a structure of function handles that could then be used by in another routine.
  1 件のコメント
Zineb EL MORCHID
Zineb EL MORCHID 2016 年 3 月 13 日
I understand now , Thank you .

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSearch Path についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by