Numerical Integration of Combined Functions with Conditional

1 Ansicht (letzte 30 Tage)
Shawn Givler
Shawn Givler am 30 Dez. 2016
Kommentiert: Walter Roberson am 31 Dez. 2016
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.

Antworten (1)

Andrei Bobrov
Andrei Bobrov am 31 Dez. 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

Community Treasure Hunt

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

Start Hunting!

Translated by