How do write a function within the same main code

15 ビュー (過去 30 日間)
Watheq Elias
Watheq Elias 2011 年 4 月 8 日
Hello everybody,
I want to know if it is possible to write a function within the same main code rather than write it in separate M file.
Thanks in advance for any help.

採用された回答

Matt Fig
Matt Fig 2011 年 4 月 8 日
Put all of this into one M-file. Then call it like this: get_sub(5)
function [OUT] = get_sub(A)
OUT = subfun(A); % Call the subfunction.
function [OUT_SUB] = subfun(B)
OUT_SUB = B.^2;
  1 件のコメント
Jan
Jan 2012 年 6 月 28 日
accepted by JSimon

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

その他の回答 (1 件)

Paulo Silva
Paulo Silva 2011 年 4 月 8 日
yes with subfunctions
  1 件のコメント
Matt Tearle
Matt Tearle 2011 年 4 月 9 日
Or nested functions

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

カテゴリ

Help Center および File ExchangeHolidays / Seasons についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by