Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %SPLOT ANALOGOWY
- function x=ACT(f1,f2,time,eps);
- %eps=0.01;
- t=0:eps:time;
- y=feval(f1,t);
- z=feval(f2,t);
- % convolution of analog signals, method from APPENDIX B
- len=length(t);
- splot=zeros(1,len);
- for i=1:len
- for k=1:i
- splot(i)=splot(i)+feval(f1,t(k)).*feval(f2,t(i)-t(k));
- end
- splot(i)=splot(i)*eps;
- x=splot(i);
- end
- subplot(4,1,1),plot(t,y);grid on
- subplot(4,1,2),plot(t,z);grid on
- subplot(4,1,3:4),plot(t,splot);grid on
- disp('value of conv at point t=');
- disp(time);
- disp('is equal to:');
- disp(x);
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- function y = Analogowa(t)
- y=2.*heaviside(t)-3.*heaviside(t-1)+heaviside(t-2);
- end
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- function y=funkcja(t)
- y=2*(t+2).*heaviside(t+2)-2*t .* heaviside(t) - ((t/2)+1).*heaviside(t-2) + ((t/2)-3).*heaviside(t-4);
- return
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- funkcja rysowanie
- t=-10:0.001:5;
- y=funkcja(t);
- plot (t,y); xlabel ('X'), ylabel('Y'), title('Sygnał'), grid on
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %Z wykladu dyskretny, dziala
- function y=splot(x1,x2,p1,p2)
- %oblicz minimalna dlugosc wektora czasu dyskretnego
- len=length(x1)+length(x2); %wektor dlugosci sygna?ów ograniczonych
- minlen=len-1;
- mv=p1+p2
- dt=(p1+p2):minlen-1+(p1+p2); % skala dyskretnego czasu
- % aby ?atwiej rysowa? i liczy? dope?nij wektory zerami
- x11=zeros(1,minlen-length(x1));
- x1=[x1 x11];
- x22=zeros(1,minlen-length(x2));
- x2=[x2 x22];
- y=zeros(1,minlen);
- for n=1:minlen %petla zewnetrzna
- for k=1:n % pętla wewn?trzna
- y(n)=y(n)+x1(k)*x2(n-k+1);
- end
- end
- %stem(dt,y)
- subplot(4,1,1); stem(dt-mv+p1,x1)
- title('Sygnal pierwszy')
- subplot(4,1,2); stem(dt-mv+p2,x2)
- title('Sygnal drugi')
- subplot(4,1,3:4); stem(dt,y); grid on
- title('Splot sygnalów')
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement