Postingan

Menampilkan postingan dengan label MATLAB

Belajar Dasar Convolution Dengan Matlab

Gambar
Berikut ini yaitu script MATLAB untuk convolution tanpa memakai function conv(). x = input('First signal '); h = input('Second signal '); a = length(x); b = length(h); n = a + b - 1; y = zeros(1,n); l = 1:n; c = 0:a - 1; d = 0:b - 1; for i = 0:n     for j = 0:n         if((i - j + 1)>0 && (i - j + 1)<=b && (j + 1)<=a)             y(i+1) = y(i+1) + x(j+1).*h(i - j +1);         end     end end disp(y); subplot(3,1,1) stem(c,x) grid on ylabel('magnitude') title('\bf First Input') subplot(3,1,2) stem(d,h) grid on ylabel('magnitude') title('\bf Second Input') subplot(3,1,3) stem(l,y) grid on ylabel('magnitude') xlabel('t') title('\bf Output')

Matlab Script Fft Sederhana

Gambar
Berikut ini ialah script MATLAB untuk melaksanakan transformasi Fourier signal discrete tanpa memakai function fft(). x=input('Input signal: '); len=length(x); y=zeros(1,len);%create an array yabs=zeros(1,len);%this line is optional, for determining its absolute value for k=1:len     for n=1:len         w=exp(-1i*2*pi*(k-1)*(n-1)/len);         a=x(n)*w;         y(k)=y(k)+a;     end     yabs(k)=abs(y(k));%this line is optional end yt=fft(x);%this one just for comparation disp(y) disp(yabs)%output's absolute value disp(yt)%fft's output figure(1) subplot(3,1,1); stem(y); subplot(3,1,2); stem(yabs); subplot(3,1,3); stem(yt); Berikut ini ialah hasil plot signal.