フィルターのクリア

why two function in separate m.file not in one ?

1 回表示 (過去 30 日間)
Abu Zar
Abu Zar 2023 年 2 月 24 日
コメント済み: Steven Lord 2023 年 2 月 25 日
statement of squeezed function is follow
squeezed(moke(n),1)=power(lema,n)*exp(-abs(lema)*abs(lema)/2)/sqrt(factorial(n));
here "moke" and "power" function is used ,"moke" is saved in another m.file while not write in same m.file ,why this written in this way ,what is the benifit ,why not in same m.file,please help.
so the squeezed and moke m-file are saved in current directory ,to run these code in which the squeezed function is use.
THANK YOU
  2 件のコメント
Jan
Jan 2023 年 2 月 24 日
I'm not sure, what your question is. The author of the code has store the code of the function moke() in a separate M-file. It is impossible to guess, why he or she decided to do so. So, why not?
Abu Zar
Abu Zar 2023 年 2 月 24 日
yes ,moke is saved in separate m.file ,so the squeezed and moke m-file are saved in current directory ,to run these code in which the squeezed function is use.

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

回答 (1 件)

Jan
Jan 2023 年 2 月 24 日
移動済み: Jan 2023 年 2 月 24 日
If you need a function inside another one only, you can store it in the same M-file. If other function should have access to the moke() function also, it must be stored in a separate M-file.
  2 件のコメント
Abu Zar
Abu Zar 2023 年 2 月 25 日
yes the moke function have access to the squeezed function.
i required a help that what is the reason to save the moke function in the in separate file,not in same file.
this is easy way?
any benifit in calculatin?
Steven Lord
Steven Lord 2023 年 2 月 25 日
Only the first function in a function file is directly callable by code outside of that function file. If you have two or more functions that you want code outside their files to be able to call them they will need to be in their own function files.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by