How does one extract/display the value of a function that is represented by a function_handle?

2 vues (au cours des 30 derniers jours)
How does one extract/display the value of a function that is represented by a function_handle?
Here is my script:
=== BEGIN ===
firstindex = 0;
lastindex = 3;
x_vector = firstindex:lastindex;
x_vector = x_vector';
n = 10;
n_vector = n*ones(size(x_vector));
p=1e-04;
p_vector = p*ones(size(x_vector));
sum_prob = @(x_vector,n_vector,p_vector) (sum(binopdf(x_vector,n_vector,p_vector)))
=== END ===
I want to see the value (i.e., a number) of sum_prob, but all I get is this:
sum_prob =
function_handle with value:
@(x_vector,n_vector,p_vector) (sum(binopdf(x_vector,n_vector,p_vector)))
  2 commentaires
Torsten
Torsten le 14 Mai 2022
To see the value, set
value = sum_prob(x_vector,n_vector,p_vector)
Roy Axford
Roy Axford le 14 Mai 2022
Torsten,
Thanks very much. That was all it took.
Best regards,
Roy

Connectez-vous pour commenter.

Réponses (0)

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by