Int returns Int when decimals input

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

John D'Errico
John D'Errico il 28 Lug 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 Commento
Leon Lazzerini
Leon Lazzerini il 29 Lug 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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Programming in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by