Numerical Integration of Combined Functions with Conditional
3 views (last 30 days)
Show older comments
I want to integrate the following function from 0 to Y for various values of Pm and Pt:
T(y) = 1/(1/Pm + N/Pt)
where N = n^2*U*y*[ 1 - exp (-n^2*U*y ) ] and U(y)=y for y<11.05 otherwise U(y)=ln(y)/K + C.
Constants are K=0.42, C=5.5, n=0.125.
I've tried to compose a combined function T(N,y) but "integral" keeps giving me errors. Anyone have any idea if this can be done.
0 Comments
Answers (1)
Andrei Bobrov
on 31 Dec 2016
Y = 20;
[p1,p2]=ndgrid(1:3,6:8);
integral(@(x)T(x,p1,p2),0,Y,'ArrayValued',1)
here T-function as m-file: T.m
function out = T(y,Pm,Pt)
K=0.42;
C=5.5;
n=0.125;
if y < 11.05
u = y;
else
u = log(y)/K + C;
end
N = n^2*u.*y.*(1 - exp (-n^2*u.*y ));
out = 1./(1./Pm + N./Pt);
end
1 Comment
See Also
Categories
Find more on Calculus 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!