Integration with piecewise function
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Fawad Ahmed
el 19 de Mzo. de 2021
Comentada: Bjorn Gustavsson
el 22 de Mzo. de 2021
Hi! I have the following problem. I have a piecewise function and i need to integrate the function with the piecewise as variable. I have type the piecewise function (see pic) but don't know where to go from there.Your help in this regard is much appreciated. T' and T are the same. I have to determine the Pf (an integral) with Cv4 (a variable of S4) as piecewise function.


4 comentarios
Walter Roberson
el 20 de Mzo. de 2021
... Is the division by the current time value, or by the upper bound?
Respuesta aceptada
Bjorn Gustavsson
el 19 de Mzo. de 2021
Doesn't this work:
C_v4 = @(T) 0.0516*T.^3.*double(T<=0.6) + .432*T.^6.7.*double(0.6<T).*double(T<1.1) + 0.468*T.^5.6.*double(1.1<=T).*double(T<=2.2);
S = @(T) integral(@(Tprime) C_v4(Tprime)./Tprime,0,T);
Then you might have to plug the piece-wise parts into a function and select what integrations you need. Perhaps something like this:
function S4 = S_4_piecewise(Tin)
if Tin > 1.1
S4 = integral(@(T) 0.0516*T.^2,0,0.6) + ...
integral(@(T) .432*T.^4.7,0.6,1.1) + ...
integral(@(T) 0.468*T.^4.6,1.1,Tin);
elseif Tin > 0.6
S4 = integral(@(T) 0.0516*T.^2,0,0.6) + ...
integral(@(T) .432*T.^5.7,0.6,Tin);
else
S4 = integral(@(T) 0.0516*T.^2,0,Tin);
end
HTH
6 comentarios
Bjorn Gustavsson
el 22 de Mzo. de 2021
Well, then you either put the contents of my function S_4_piecewise inside a loop such that integral can use it, or you do it by hand. And by doing it by hand I mean do it properly, such that you can implement the result in a matlab-function where you also send in parameters for the coefficients and the temperature limits.
Más respuestas (0)
Ver también
Categorías
Más información sobre Numerical Integration and Differentiation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!