フィルターのクリア

How to call a function within another function in MATLAB?

6 ビュー (過去 30 日間)
Tanvir Kaisar
Tanvir Kaisar 2017 年 3 月 21 日
編集済み: Jan 2017 年 3 月 21 日
I want to call a second function within the first function and use the output of the first function as input to the second function

回答 (2 件)

Jan
Jan 2017 年 3 月 21 日
編集済み: Jan 2017 年 3 月 21 日
The question is not clear: "call a second function within the first function" - this sounds easy, but "use the output of the first function as input to the second function" is something completely different.
  • The first part:
function y = fcn1(a, b);
c = function2(a);
y = a + c;
end
function c = fcn2(a)
c = cos(a);
end
The fcn2 can either be defined in an own M-file or contained in the M-file of fcn1. If it is used inside fcn1 only, you can use a nested function also. Please read https://www.mathworks.com/help/matlab/ref/function.html.
  • The second part:
y = fcn1(a, b);
z = fcn2(y);
Perhaps you should edit your question and clarify it.

ES
ES 2017 年 3 月 21 日
This one?
https://www.mathworks.com/help/matlab/matlab_prog/nested-functions.html

カテゴリ

Help Center および File ExchangeSimulink Real-Time についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by