Int returns Int when decimals input

1 Ansicht (letzte 30 Tage)
Leon Lazzerini
Leon Lazzerini am 28 Jul. 2020
Kommentiert: Leon Lazzerini am 29 Jul. 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.

Akzeptierte Antwort

John D'Errico
John D'Errico am 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 Kommentar
Leon Lazzerini
Leon Lazzerini am 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by