how to overcome undefined function sum.

throughput_E =@(t)Bmax*log2(1+p_fix(t)*gamma(t)/sum(p_fix(q,1,t-1).*gamma(t)));
overall_throughput_E = sum(sum(throughput_E));
If i run the code i am getting Undefined function 'sum' for input arguments of type 'function_handle'.
Error in overall_throughput_E = sum(sum(throughput_E));

4 comentarios

KSSV
KSSV el 29 de Dic. de 2017
define p_fix as a anonymous function and try.
Prabha Kumaresan
Prabha Kumaresan el 29 de Dic. de 2017
Editada: Matt J el 29 de Dic. de 2017
throughput_E = @(t)Bmax*log2(1+p_fix(t)*gamma(t)/symsum(p_fix(q,1,t-1).*gamma(t)))
overall_throughput_E = sum(sum(throughput_E));
after using anonymous function i am stiil getting
Undefined function 'sum' for input arguments of type 'function_handle'.
Error in overall_throughput_E =
sum(sum(throughput_E));
KSSV
KSSV el 29 de Dic. de 2017
:( what is p_fix.....show us this function.
Prabha Kumaresan
Prabha Kumaresan el 29 de Dic. de 2017
p_fix is the fixed power which was given by 0.01 .

Iniciar sesión para comentar.

Respuestas (1)

Matt J
Matt J el 29 de Dic. de 2017
Editada: Matt J el 29 de Dic. de 2017
You need to give some sort of input to throughput_E in this line
sum(sum( throughput_E( t_input) ));

3 comentarios

To amplify on what Matt said, and explain why there was a problem...
throughput_E is a function handle. It seems like it makes sense that you can sum the function, simply by putting it inside sum. But MATLAB does not understand your goal here. MATLAB is a very literal tool. The function sum looks at what you passed in. Sum recognizes only numeric inputs as candidates to be summable. It looks at throughput_E, and sees that it is NOT a number or vector or array of numbers. So sum just gives up and throws an error.
If you change things, so that throughput_E has an input as did Matt, then the result is now numeric. MATLAB evaluates the function at t_input, then passes the result to sum. All is good now.
Sometimes you really don't immediately have the input to throughput_E at the moment, but you want to define a new function that will take any input and sum the result, after going through throughput_E? Just create a NEW function, as I do here:
sum_of_throughput_E = @(inp) sum(sum(throughput_E(inp)));
So now you can use this new function as the summed result.
Prabha Kumaresan
Prabha Kumaresan el 29 de Dic. de 2017
Editada: Walter Roberson el 29 de Dic. de 2017
i am getting the error
Undefined function or variable 't_input'
if i use sum(sum( throughput_E( t_input) ));
and if i use
sum_of_throughput_E = @(inp) sum(sum(throughput_E(inp)));
in the below coding
throughput_E = @(t)Bmax*log2(1+p_fix(t)*gamma(t)/symsum(p_fix(q,1,t-1).*gamma(t)))
% overall_throughput_E = sum(sum(throughput_E(t_input)));
overall_throughput_E = sum(sum(throughput_E));
sum_of_throughput_E = @(inp) sum(sum(throughput_E(inp)));
%
output_E(t,r)=overall_throughput_E;
output_E_it(t,r,it)=output_E(t,r);
i am getting Undefined function 'sum' for input arguments of type 'function_handle'.
Error in
overall_throughput_E = sum(sum(throughput_E));
Please help me to solve it.
Matt J
Matt J el 29 de Dic. de 2017
Editada: Matt J el 29 de Dic. de 2017
Undefined function or variable 't_input'
You must define t_input! What data are you trying to run throughput_E on?

Iniciar sesión para comentar.

Categorías

Más información sobre Mathematics en Centro de ayuda y File Exchange.

Preguntada:

el 29 de Dic. de 2017

Editada:

el 29 de Dic. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by