Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Zadanie 1, grupa A - METODA EULERA
- clear
- figure
- function f=funkcja(x,y)
- f=2*y+8*x
- endfunction
- h=0.01
- x=1.5:h:3.5
- y(1)=2
- for i=1:2/h
- y(i+1)=y(i)+h*funkcja(x(i),y(i))
- end
- plot(x,y,'m')
- legend('METODA EULERA - h=0.01',4)
- xgrid
- //Zadanie 1, grupa B - METODA ZMODYFIKOWANA EULERA
- figure
- clear
- function f=funkcja(x,y)
- f=3*x^2-y
- endfunction
- h=0.01
- x=0:h:5
- y(1)=0
- for i=1:5/h
- y0=y(i)+h*funkcja(x(i),y(i))
- y(i+1)=y(i)+h*(funkcja(x(i),y(i))+funkcja(x(i+1),y0))/2
- end
- plot(x,y,'b')
- legend('METODA ZMODYFIKOWANA EULERA',4)
- xgrid
- //Zadanie 1, grupa TOB - METODA RALSONA
- figure
- clear
- function f=funkcja(x,y)
- f=6*x^2+6
- endfunction
- h=0.01
- y(1)=7
- x=2:h:12
- for i=1:10/h
- k1=funkcja(x(i),y(i))
- k2=funkcja(x(i)+0.75*h,y(i)+0.75*k1*h)
- y(i+1)=y(i)+(1/3*k1+2/3*k2)*h
- end
- plot(x,y,'y')
- xgrid
- legend('METODA RALSONA')
- //Zadanie 2, grupa A - METODA OBSZARÓW KOLOKACJI
- clear
- figure
- n11=integrate ('1-x' , 'x' , 0, 1/3)
- n12=integrate ('2*x-x^2' , 'x' , 0 ,1/3)
- n13=integrate ('-x^3+3*x^2' , 'x' , 0 ,1/3)
- n21=integrate ('1-x' , 'x' , 1/3, 2/3)
- n22=integrate ('2*x-x^2' , 'x' , 1/3, 2/3)
- n23=integrate ('-x^3+3*x^2' , 'x' , 1/3, 2/3)
- n31=integrate ('1-x' , 'x' , 2/3, 1)
- n32=integrate ('2*x-x^2' , 'x' , 2/3, 1)
- n33=integrate ('-x^3+3*x^2' , 'x' , 2/3, 1)
- q1=integrate ('x-1.5' , 'x' , 0 , 1/3)
- q2=integrate ('x-1.5' , 'x' , 1/3 , 2/3)
- q3=integrate ('x-1.5' , 'x' , 2/3 , 1)
- A3=[n11 , n12, n13 ; n21 , n22 , n23 ; n31 , n32 , n33]
- b3=[q1;q2;q3]
- t3=linsolve (A3,b3)
- x=0:0.1:1
- y3=1.5+t3(1,1)*x+t3(2,1)*x^2+t3(3,1)*x^3
- plot (x,y3,'.-g')
- legend('METODA OBSZARÓW KOLOKACJI',4)
- xgrid
- //Zadanie 2, TOB - METODA PUNKTÓW KOLOKACJI
- figure
- clear
- x=3:0.01:4
- k1=10/3
- k2=11/3
- A2=[13.407 , 136.222;16.148 , 112.889]
- b2=[-23.333;-26.666]
- t2=linsolve (A2,b2)
- x=3:0.01:4
- y2=x+t2(1,1).*(x-3).*(x-4).*x+t2(2,1)*(x-3).*(x-4)
- plot (x,y2, 'm')
- legend('METODA PUNKTÓW KOLOKACJI',4)
- xgrid
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement