Смекни!
smekni.com

Дослідження методів інтерполяції (стр. 3 из 3)

Література

1. Квєтний Р.Н. Методи комп’ютерних обчислень. Навчальний посібник. -Вінниця: ВДТУ, 2001.

2. Фаронов В.В. Турбо Паскаль 7.0. Начальний курс. Учебное пособие. -М.: Издательство "ОМД Групп", 2003.

3. Бахвалов Н.С., Жидков Н.П., Кобельков Г.М. Численные методы. - М.: Наука, 1987.

4. Дубовий В. М, Квєтний Р.Н. Основи застосування ЕОМ у інженерній діяльності. -К.: ІСДО України, 1994.

5. Глинський Я.М., Анохін В. Є., Ряжська В.А. Паскаль. 3-є вид. - Львів: "Деол", 2002.

Додатки

Додаток А. Блок-схема основної програми

Додаток Б. Лістинг програми

Program interpol;

Uses Crt,Graph;

Const t1=75; t2=93;

T: array [0. .5] of integer = (20,40,60,80,100,120);

U: array [0. .5] of real = (-0.67,-0.25,-0.17,0.61,1.06,1.52);

Var

A1: array [0. .5] of real;

A2: array [0. .5] of real;

A3: array [0. .5] of real;

A4: array [0. .5] of real;

A5: array [0. .5] of real;

driver,mode, i,j: integer;

x,x1,dx,y,y1,dy0,dy1,dy2,dy3,dy4,dy5,dy6,dy7: integer;

e,PP,P1,P2,Z1,Z2,ZZ: real; Ch: char;

LL0,LL1,LL2,LL3,LL4,LL5: real;

{----------------------------------------------------------------------------------------}

{TABLUCIA}

{----------------------------------------------------------------------------------------}

procedure tabluca;

begin

TextBackGround (white);

ClrScr;

TextColor (red);

Writeln ('');

GoToXY (20,10);

Writeln ('TARUROVO4NA TABLUCIA DLIA TERMOPARU');

GoToXY (15,12);

Writeln ('------------------------------------------------');

GoToXY (15,13);

Writeln ('| T,C | 20 | 40 | 60 | 80 | 100 | 120 |');

GoToXY (15,14);

Writeln ('------------------------------------------------');

GoToXY (15,15);

Writeln ('|U,mV | - 0.67| - 0.25| - 0.17| 0.61 | 1.06 | 1.52|');

GoToXY (15,16);

Writeln ('------------------------------------------------');

end;

{----------------------------------------------------------------------------------------}

{-------------------------Graphik-----------------------------------------------------}

procedure graphik (driver,mode,x,x1,dx,y,y1,dy0,dy1,dy2,dy3,dy4,dy5,dy6,dy7: integer);

begin

driver: =detect;

initgraph (driver,mode,'C: \progra~1\TP\bgi');

setviewport (20, 20,getmaxx-59,getmaxy-59,true);

clearviewport;

setbkcolor (white);

x: =20; y: =20;

dy0: = (getmaxy div 2 - (trunc (80*u [0])));

dy1: = (getmaxy div 2 - (trunc (80*u [1])));

dy2: = (getmaxy div 2 - (trunc (80*u [2])));

dy3: = (getmaxy div 2 - (trunc (80*PP)));

dy4: = (getmaxy div 2 - (trunc (80*u [3])));

dy5: = (getmaxy div 2 - (trunc (80*ZZ)));

dy6: = (getmaxy div 2 - (trunc (80*u [4])));

dy7: = (getmaxy div 2 - (trunc (80*u [5])));

dx: =t [1] -t [0] ;

setcolor (red);

line (4*dx,dy0,6*dx,dy1);

line (6*dx,dy1,8*dx,dy2);

line (8*dx,dy2,6*dx+t1,dy3);

line (6*dx+t1,dy3,10*dx,dy4);

line (10*dx,dy4,7*dx+t2,dy5);

line (7*dx+t2,dy5,12*dx,dy6);

line (12*dx,dy6,14*dx,dy7);

repeat

setcolor (green);

line (20,y,getmaxx,y);

line (x, 20,x,getmaxy);

x: =x+20; y: =y+20;

y1: =getmaxy div 2;

setcolor (blue);

outtextxy (2*20,y1,'0 20 40 60 80 100 120');

outtextxy (20,y1-60*2,' 1.5');

outtextxy (20,y1-40*2,' 1.0');

outtextxy (20,y1-20*2,' 0.5');

outtextxy (20,y1+60*2,'-1.5');

outtextxy (20,y1+40*2,'-1.0');

outtextxy (20,y1+20*2,'-0.5');

until keypressed;

if readkey=#0 then driver: =ord (readkey);

closegraph

end;

{---------------------ZASTAVKA--------------------------------------------------}

{---------------------------------------------------------------------------------------}

procedure zastavka;

begin

clrscr; GoToXY (14,2);

Writeln (' (C) CopyRight by Alexander Kyrsta, BHTY, 1AM-03');

GoToXY (29,5); Writeln ('PROGRAM INTERPOL, 2006');

Writeln; GoToXY (32,13); Writeln ('VUBERITb METOD'); Writeln;

GoToXY (24,15); Writeln ('1-METOD ROZPODILENUX RIZNUCb. ');

GoToXY (24,17); Writeln (' 2-METOD LAGRANJA. ');

GotoXY (24,25); Writeln (' Press Esc+Enter for exit ');

end;

{-------------------------------------------------------------------}

{------------------OSNOVNA PROGRAMA------------------------------------}

begin

zastavka;

repeat

ch: =readkey;

case ch of

{-------------METOD ROZPODILENUX RIZNUCb----------------------------}

#49: begin

{ROZPODILENI RIZNUCI 1 PORIADKY}

for i: =0 to 4 do begin

a1 [i]: = ( (u [i+1] -u [i]) / (t [i+1] -t [i]));

{writeln (a1 [i]: 3: 6); } end;

{ROZPODILENI RIZNUCI 2 PORIADKY}

for i: =0 to 3 do begin

a2 [i]: = ( (a1 [i+1] -a1 [i]) / (t [i+2] -t [i]));

{writeln (a2 [i]: 3: 7); } end;

{ROZPODILENI RIZNUCI 3 PORIADKY}

for i: =0 to 2 do begin

a3 [i]: = ( (a2 [i+1] -a2 [i]) / (t [i+3] -t [i]));

{writeln (a3 [i]: 3: 16); } end;

{ROZPODILENI RIZNUCI 4 PORIADKY}

for i: =0 to 1 do begin

a4 [i]: = ( (a3 [i+1] -a3 [i]) / (t [i+4] -t [i]));

{writeln (a4 [i]: 3: 16); } end;

{ROZPODILENI RIZNUCI 5 PORIADKY}

for i: =0 to 0 do begin

a5 [i]: = ( (a4 [i+1] -a4 [i]) / (t [i+5] -t [i]));

{writeln (a5 [i]: 3: 16); } end;

clrscr; tabluca;

P1: =u [0] +a1 [0] * (t1-t [0]) +a2 [0] * (t1-t [0]) * (t1-t [1]) +a3 [0] * (t1-t [0]) * (t1-t [1]) * (t1-t [2]);

P2: =a4 [0] * (t1-t [0]) * (t1-t [1]) * (t1-t [2]) * (t1-t [3]) +a5 [0] * (t1-t [0]) * (t1-t [1]) * (t1-t [2]) * (t1-t [3]) * (t1-t [4]);

PP: =P1+P2;

Z1: =u [0] +a1 [0] * (t2-t [0]) +a2 [0] * (t2-t [0]) * (t2-t [1]) +a3 [0] * (t2-t [0]) * (t2-t [1]) * (t2-t [2]);

Z2: =a4 [0] * (t2-t [0]) * (t2-t [1]) * (t2-t [2]) * (t2-t [3]) +a5 [0] * (t2-t [0]) * (t2-t [1]) * (t2-t [2]) * (t2-t [3]) * (t2-t [4]);

ZZ: =Z1+Z2;

writeln; GoToXY (25,17);

writeln ('Pru T=75C U=',PP: 2: 6,'mV');

Writeln; GoToXY (25,18);

writeln ('Pru T=93C U=',ZZ: 2: 6,'mV');

GoToXY (30,22);

writeln ('PRESS ENTER');

readln;

graphik (x,x1,dx,y,y1,dy0,dy1,dy2,dy3,dy4,dy5,dy6,dy7,driver,mode);

end;

{-------METOD LAGRANJA-------------------------------------------------------}

#50: begin

clrscr; tabluca;

e: =t1;

LL0: =u [0] * (e-40) * (e-60) * (e-80) * (e-100) * (e-120) / ( (20-40) * (20-60) * (20-80) * (20-100) * (20-120));

LL1: =u [1] * (e-20) * (e-60) * (e-80) * (e-100) * (e-120) / ( (40-20) * (40-60) * (40-80) * (40-100) * (40-120));

LL2: =u [2] * (e-20) * (e-40) * (e-80) * (e-100) * (e-120) / ( (60-20) * (60-40) * (60-80) * (60-100) * (60-120));

LL3: =u [3] * (e-20) * (e-40) * (e-60) * (e-100) * (e-120) / ( (80-20) * (80-40) * (80-60) * (80-100) * (80-120));

LL4: =u [4] * (e-20) * (e-40) * (e-60) * (e-80) * (e-120) / ( (100-20) * (100-40) * (100-60) * (100-80) * (100-120));

LL5: =u [5] * (e-20) * (e-40) * (e-60) * (e-80) * (e-100) / ( (120-20) * (120-40) * (120-60) * (120-80) * (120-100));

PP: =LL0+LL1+LL2+LL3+LL4+LL5;

writeln; GoToXY (25,17);

writeln ('Pru T=75C U=',PP: 3: 6,'mV');

e: =t2;

LL0: =u [0] * (e-40) * (e-60) * (e-80) * (e-100) * (e-120) / ( (20-40) * (20-60) * (20-80) * (20-100) * (20-120));

LL1: =u [1] * (e-20) * (e-60) * (e-80) * (e-100) * (e-120) / ( (40-20) * (40-60) * (40-80) * (40-100) * (40-120));

LL2: =u [2] * (e-20) * (e-40) * (e-80) * (e-100) * (e-120) / ( (60-20) * (60-40) * (60-80) * (60-100) * (60-120));

LL3: =u [3] * (e-20) * (e-40) * (e-60) * (e-100) * (e-120) / ( (80-20) * (80-40) * (80-60) * (80-100) * (80-120));

LL4: =u [4] * (e-20) * (e-40) * (e-60) * (e-80) * (e-120) / ( (100-20) * (100-40) * (100-60) * (100-80) * (100-120));

LL5: =u [5] * (e-20) * (e-40) * (e-60) * (e-80) * (e-100) / ( (120-20) * (120-40) * (120-60) * (120-80) * (120-100));

ZZ: =LL0+LL1+LL2+LL3+LL4+LL5;

writeln; GoToXY (25, 19);

writeln ('Pru T=93C U=',ZZ: 3: 6,'mV');

GoToXY (30,22);

writeln ('PRESS ENTER');

readln;

graphik (x,x1,dx,y,y1,dy0,dy1,dy2,dy3,dy4,dy5,dy6,dy7,driver,mode);

end;

end;

zastavka;

until ch=#27;

readln

end.

Додаток Г. Результати роботи програми