Effacer les filtres
Effacer les filtres

How to nest functions?

1 vue (au cours des 30 derniers jours)
Sergey Dukman
Sergey Dukman le 14 Jan 2016
Commenté : Sergey Dukman le 14 Jan 2016
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 commentaires
jgg
jgg le 14 Jan 2016
Modifié(e) : jgg le 14 Jan 2016
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 le 14 Jan 2016
Modifié(e) : Walter Roberson le 14 Jan 2016
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 :)

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 14 Jan 2016
Example:
d = @(N) 23.45*(sind((360/365)*(284+N)));
N = 0:20;
B = 98.8;
C = B .* d(N);
  1 commentaire
Sergey Dukman
Sergey Dukman le 14 Jan 2016
Thank you, sir

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by