Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- run_loop=1;
- while run_loop==1
- x=input('enter the sequence under []:\n');
- xstr=int2str(x);
- N=input('how many point dft? enter value of N:\n');
- fprintf('\n')
- for p=0:1:(N/2-1)
- e=exp(-i*(2*pi/N)*p);
- a=horzcat('[',int2str(real(e)),' ',int2str(imag(e)),'j',']','<- this is a string only');
- fprintf('W%d = %s\n',p,a)
- end
- y=fft(x,N)
- ystr=int2str(y);
- yABS=abs(y);
- yANG=angle(y);
- n=0:1:(N-1);
- subplot(2,2,1)
- stem(n,x)
- xlabel('samples')
- ylabel('amplitude')
- title(['input sequence:',xstr])
- subplot(2,2,2)
- stem(n,y)
- xlabel('samples')
- ylabel('amplitude')
- title(['output sequence:',ystr])
- subplot(2,2,3)
- stem(n,yABS)
- xlabel('samples')
- ylabel('amplitude')
- title('magnitude of DFT')
- subplot(2,2,4)
- stem(n,yANG)
- xlabel('samples')
- ylabel('amplitude')
- title('angle of DFT')
- run_loop=input('continue with another fft? 1(YES), 0(NO):')
- end
Advertisement
Add Comment
Please, Sign In to add comment