Int returns Int when decimals input

1 visualización (últimos 30 días)
Leon Lazzerini
Leon Lazzerini el 28 de Jul. de 2020
Comentada: Leon Lazzerini el 29 de Jul. de 2020
Hey guys! I've done this simple function:
function [CCp] = IntCCpfunction (wi,wr,vr,vi,k,c)
syms w
l = (vr-vi)/vi;
p = w/wr;
f2 = w-wi;
fw = ((k*l*vi)/c)*(((1+p*l)*vi)/c)^(k-1)*exp(-((1+p*l)*vi)/c)^k ;
fp = (f2*fw);
CCp = int(fp,w);
end
The problem is, when i use k or c as decimals ( 2.1, 10.2 etc) the function doesn't calculate the integral. Maybe somebody could help me undestand the problem?
*Note: With ''normal'' values or decimals (wi,wr,vr,vi) it's working, so i imagine the problem has to do with the exp.

Respuesta aceptada

John D'Errico
John D'Errico el 28 de Jul. de 2020
fw = ((k*l*vi)/c)*(((1+p*l)*vi)/c)^(k-1)*exp(-((1+p*l)*vi)/c)^k ;
When k is some non-integer value, you are raising some non-trivial stuff to non-integer powers. Then you want to integrate it?
It won't happen. That is, you won't find an analytical result. When int just returns the integral form, this tells you there is no such solution.
If all of the other parameters also have numerical values, you can always use integral instead.
  1 comentario
Leon Lazzerini
Leon Lazzerini el 29 de Jul. de 2020
Ohh i see, that's unfortunate. The problem with integral is that i can't use the limits, i need the answer with the w to get a cost function to posteriorly derivate it.
Thanks a lot for your answer, i really couldn't understand the problem.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by