Int returns Int when decimals input

1 view (last 30 days)
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.

Accepted Answer

John D'Errico
John D'Errico on 28 Jul 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 Comment
Leon Lazzerini
Leon Lazzerini on 29 Jul 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.

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!