필터 지우기
필터 지우기

How to nest functions?

조회 수: 1 (최근 30일)
Sergey Dukman
Sergey Dukman 2016년 1월 14일
댓글: Sergey Dukman 2016년 1월 14일
Hello, I have a function. Then I want to create another function and use the value of the first function to compute the second one. How can I "connect" these functions?
Regards, Sergey
  댓글 수: 2
jgg
jgg 2016년 1월 14일
편집: jgg 2016년 1월 14일
I'm unclear what you want to do exactly. Functions can call each other:
F = @(X)(X + 2)
G = @(X)(2*F(X) + F(4))
G(F(2))
Are all valid.
Sergey Dukman
Sergey Dukman 2016년 1월 14일
편집: Walter Roberson 2016년 1월 14일
I have the following function:
function epsilon = d(N)
epsilon=23.45*(sind((360/365)*(284+N)));
end
Then I want to create another function in order to compute equation based on value of first function. Let's say that the value of the first function is A. Then the second function will be defined as
C=B*A.
Hopefully you understood :)

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2016년 1월 14일
Example:
d = @(N) 23.45*(sind((360/365)*(284+N)));
N = 0:20;
B = 98.8;
C = B .* d(N);
  댓글 수: 1
Sergey Dukman
Sergey Dukman 2016년 1월 14일
Thank you, sir

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by