Termovizijski sistemi MS1TS Vežbe 02 primer 1 MATLAB funkcija conv. f x = rect x rect x 2 ( ) ( ) ( ) y=conv(rectangle_function(x),rectangle_function(x-2)); figure,subplot(3,1,1),plot(x,rectangle_function(x)),xlabel('\itx'),ylabel('rect({\itx})'); subplot(3,1,2),plot(x,rectangle_function(x-2)),xlabel('\itx'),ylabel('rect({\itx}-2)'); subplot(3,1,3),plot(y),xlabel('\itx'),ylabel('rect({\itx})*rect({\itx}-2)'), title('konv. je "pomerena" po {\itx} osi i skalirana po {\ity} osi u odnosu na teorijsku vrednost!!!'); primer 2 MATLAB funkcija conv - dodatne opcije. y=conv(rectangle_function(x),rectangle_function(x-2),'same'); figure,subplot(3,1,1),plot(x,rectangle_function(x)),xlabel('\itx'),ylabel('rect({\itx})'); subplot(3,1,2),plot(x,rectangle_function(x-2)),xlabel('\itx'),ylabel('rect({\itx}-2)'); subplot(3,1,3),plot(x,y),xlabel('\itx'),ylabel('rect({\itx})*rect({\itx}-2)'), title('konv. je "na pravom mestu" po {\itx} osi ali je skalirana po {\ity} osi u odnosu na teor. vrednost!!!');
primer 3 MATLAB funkcija conv - racunanje konvolucije kontinualnih signala. dx=0.1; y=dx*conv(rectangle_function(x),rectangle_function(x-2),'same'); figure,subplot(3,1,1),plot(x,rectangle_function(x)),xlabel('\itx'),ylabel('rect({\itx})'); subplot(3,1,2),plot(x,rectangle_function(x-2)),xlabel('\itx'),ylabel('rect({\itx}-2)'); subplot(3,1,3),plot(x,y),xlabel('\itx'),ylabel('rect({\itx})*rect({\itx}-2)'), title('konv. je "na pravom mestu" po {\itx} osi ali je skalirana po {\ity} osi u odnosu na teor. vrednost!!!');
primer 4 MATLAB funkcija conv - racunanje konvolucije kontinualnih signala. y( x) = f ( x) δ ( x x ) y y y ( x) = f ( u) δ ( x x u) ( x) = f ( u) δ ( ( u ( x x ))) 0 0 ( x) = f ( u) δ ( u ( x x )) du = f ( x x ) 0 du 0 du 0 dx=0.1; y=dx*conv(rectangle_function(x),gaus_function((x-2)/0.001)/0.001,'same'); figure,subplot(3,1,1),plot(x,rectangle_function(x)),xlabel('\itx'),ylabel('rect({\itx})'); subplot(3,1,2),plot(x,gaus_function((x-2)/0.001)/0.001),xlabel('\itx'),ylabel('\delta({\itx}-2)'); subplot(3,1,3),plot(x,y),xlabel('\itx'),ylabel('rect({\itx})*\delta({\itx}-2)'), title('konv. je Ok po obe ose u odnosu na teorijsku vrednost!!!');
primer 5 MATLAB funkcija conv - racunanje konvolucije kontinualnih signala. y( x) = δδ ( x) δδ ( x) δδ ( x) = δ ( x + 1) + δ ( x 1) y( x) = [ δδ ( x) δ ( x + 1) ] + [ δδ ( x) δ ( x 1) ] y( x) = δδ ( x + 1) + δδ ( x 1) y( x) = δ ( x + 2) + δ ( x) + δ ( x) + δ ( x 2) y( x) = δ ( x + 2) + 2δ ( x) + δ ( x 2) dx=0.1; delta_2=gaus_function((x-1)/0.001)/0.001+gaus_function((x+1)/0.001)/0.001; y=dx*conv(delta_2,delta_2,'same'); figure,subplot(2,1,1),plot(x,delta_2),xlabel('\itx'),ylabel('\delta_p({\itx})'); subplot(2,1,2),plot(x,y),xlabel('\itx'),ylabel('\delta_p({\itx})*\delta_p({\itx})');
primer 6 MATLAB funkcija conv - racunanje konvolucije kontinualnih signala. dx=0.1; y=dx*conv(rectangle_function(x),rectangle_function(x/3),'same'); figure,subplot(3,1,1),plot(x,rectangle_function(x)),xlabel('\itx'),ylabel('rect({\itx})'); subplot(3,1,2),plot(x,rectangle_function(x/3)),xlabel('\itx'),ylabel('rect({\itx}/3)'); subplot(3,1,3),plot(x,y),xlabel('\itx'),ylabel('rect({\itx})*rect({\itx}/3)');
primer 7 MATLAB funkcija conv - racunanje konvolucije kontinualnih signala. dx=0.1; y=dx*conv(triangle_function(x-2),triangle_function(x/3),'same'); figure,subplot(3,1,1),plot(x,triangle_function(x-2)),xlabel('\itx'),ylabel('tri({\itx}-2)'); subplot(3,1,2),plot(x,triangle_function(x/3)),xlabel('\itx'),ylabel('rect({\itx}/3)'); subplot(3,1,3),plot(x,y),xlabel('\itx'),ylabel('tri({\itx}-2)*rect({\itx}/3)'); primer 8 MATLAB funkcija conv - racunanje konvolucije kontinualnih signala. dx=0.1; y=dx*conv(gaus_function(x-2),gaus_function(x/3),'same'); figure,subplot(3,1,1),plot(x,gaus_function(x-2)),xlabel('\itx'),ylabel('gaus({\itx}-2)'); subplot(3,1,2),plot(x,gaus_function(x/3)),xlabel('\itx'),ylabel('gaus({\itx}-2)'); subplot(3,1,3),plot(x,y),xlabel('\itx'),ylabel('gaus({\itx}-2)*gaus({\itx}/3)');
primer 9 Dvodimenzionalne funkcije koje "razdvajaju" promenljive. g( x, y) = g X ( x) gy ( y) g( r, θ ) = g ( r) g ( θ ) R Θ x=(-10:0.01:10); y=(-3:0.01:3); [X,Y,Z]=rectangle_2_function(x-5,y); figure,mesh(x,y,z),xlabel('\itx'),ylabel('\ity'),zlabel('rect({\itx}-5)rect({\ity})'); title('{\itx}-{\ity} "mreža" nije Ok!!!'); figure,mesh(x,y,z),view([0 90]),xlabel('\itx'),ylabel('\ity'), title('rect({\itx}-5)rect({\ity}), {\itx}-{\ity} "mreža" nije Ok!!!');
primer 10 Dvodimenzionalne funkcije koje "razdvajaju" promenljive. x=(-10:0.01:10); y=(-3:0.01:3); [X,Y,Z]=rectangle_2_function(x-5,y); [X,Y]=meshgrid(x,y);
figure,mesh(x,y,z),xlabel('\itx'),ylabel('\ity'),zlabel('rect({\itx}-5)rect({\ity})'); title('{\itx}-{\ity} "mreža" Ok!!!'); figure,mesh(x,y,z),view([0 90]),xlabel('\itx'),ylabel('\ity'),title('rect({\itx}-5)rect({\ity})'); primer 11 Dvodimenzionalne funkcije koje "razdvajaju" promenljive.
x=(-5:0.01:5); y=(-5:0.01:5); [X,Y,Z]=rectangle_2_function((x-3)/3,(y-2)/2); [X,Y,W]=rectangle_2_function((x+3)/4,(y-2)/3); [X,Y]=meshgrid(x,y); figure,mesh(x,y,z+2*w),xlabel('\itx'),ylabel('\ity'),zlabel('{\itz}+{\itw}'); figure,mesh(x,y,z+2*w),view([0 90]),xlabel('\itx'),ylabel('\ity'),title('{\itZ}+{\itW}');
primer 12 Dvodimenzionalne funkcije koje "razdvajaju" promenljive. x=(-20:0.1:20); y=(-20:0.1:20); [X,Y,Z]=triangle_2_function((x-9)/7,(y-13)/5); [X,Y]=meshgrid(x,y); figure,mesh(x,y,z),xlabel('\itx'),ylabel('\ity'),zlabel('tri(({\itx}-9)/7)tri(({\ity}-13)/5)'); figure,mesh(x,y,z),view([0 90]),xlabel('\itx'),ylabel('\ity'), title('tri(({\itx}-9)/7)tri(({\ity}-13)/5)');
primer 13 Odredjivanje konvolucije numeričkom integracijom. x=(-20:0.01:20)'; for brojac=1:length(x) xt=x(brojac); r_f=@(t) rectangle_function(t).*rectangle_function(xt-t-2); y(brojac)=quad(r_f,max(-1/2,-5/2+xt),min(1/2,3/2+xt)); end; plot(x,y),xlabel('\itx'),ylabel('rect({\itx})*rect({\itx}-2)');