algoritme of Simpson

1 Ansicht (letzte 30 Tage)
Stijn
Stijn am 7 Apr. 2012
hej,
I got a question about making the algoritme myself, because the funtion i am going to calculate is too big for matlab (or it takes several days to complete).
My problem: I am trying to create a loop in matlab
%Constant
Cpl=1.006;
Cpd=1.86;
Cpw=4.183;
Ro=2500;
Pa=1.01325;
%IMS
Tnb=22;
Ti=34;
Tu=31;
Mw=5;
Ml=2;
%methode van Simpson
n=10; %interval
h=(Ti-Tu)/(2*n);
%hli-formules to make hli
hli=Cpl*Tnb+wTnb*(Ro+Cpd*Tnb);
PsTnb=(6.1121*exp(((18.678-(Tnb/234.5))*Tnb)/(257.14+Tnb)))/1000;
wTnb=0.622*(PsTnb/(Pa-PsTnb));
%formules needed for simpson
Ps=(6.1121*exp(((18.678-(Tw/234.5))*Tw)/(257.14+Tw)))/1000;
w=0.622*(Ps/(Pa-Ps));
hs=Cpl*Tw+w*(Ro+Cpd*Tw);
hl=hli+((Mw*Cpw)/Ml)*(Tw-Tu);
F=(1/(hs-hl));
I wil try to explain the loob: I need "F" for every temperature "Tw" starting with temperature "Ti" and ending with temperature "Tu" and with steps of "h".
For this example:(this is what the loob needs to be doing)
F0=(1/(hs(Ti)-hl(Ti))) --> store in matrix first row
F1=(1/(hs(Ti+h)-hl(Ti+h))) --> store in matrix second row
...
F2n=(1/(hs(Ti+2nh)-hl(Ti+2nh)))=1/(hs(Tu)-hl(Tu)) --> store in matrix last row
So if i run it, it will give me a matrix with all the values of "F"
with these matrix i can calculate the integral by using
y=(h/3)*((F0+F2n)+4*(F1+F3+F5+...+F2n-1)+2*(F2+F4+F6+...+F2n-2))
thanks in advance
Stijn

Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by