How to see the content of a function handle?

2 vues (au cours des 30 derniers jours)
rasoul rad
rasoul rad le 22 Déc 2016
Commenté : rasoul rad le 22 Déc 2016
Hi, I'm trying to create a function handle with 2 variables like x(1) and x(2) and use this function into next command lines to create other functions. for example assume these lines:
Dh = @(x) ((4*x(1)))/((x(1)+sin(x)));
G = @(x) (1/(10*x(1)));
Re = @(x) ((G(x)*Dh(x)));
Now, if i want to see the content of variable "Re", the MATLAB will answer like this:
>> Re
Re =
function_handle with value:
@(x)((G(x)*Dh(x)))
I want to see "Re" in mathematic shape like this:
4
----------------
10 x + 10 sin(x)
How can i do this? I'll be grateful for any help.

Réponse acceptée

Walter Roberson
Walter Roberson le 22 Déc 2016
You would need the symbolic toolbox.
Dh = @(x) ((4*x(1)))./((x(1)+sin(x))); %note correction to use ./ instead of /
G = @(x) (1/(10*x(1)));
Re = @(x) ((G(x)*Dh(x)));
x = sym('x', [1 2]);
pretty( Re(x) )
  1 commentaire
rasoul rad
rasoul rad le 22 Déc 2016
Perfect answer. Thank you.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with MATLAB 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