I have been having Problem in Taking DFT of a Swept Sine Signal, my code is below, please Review the Code and Let me give some Suggestions if true amp=4;
t1=str2num(get(handles.t1,'String')); t2=str2num(get(handles.t2,'String')); dt=str2num(get(handles.interval,'String')); t=t1:dt:t2; ValF=str2num(get(handles.startf,'String')); ValF1=str2num(get(handles.endf,'String')); f1=2*pi*ValF; f2=2*pi*ValF1; f= ((f2-f1).*t/(t2-t1)) + f1; % Define the time vector
y = amp .* sin(f .* t); % Compute y(t), the sine wave
plot(t,y) % Plot y vs. t
xlabel('Time (seconds)') % Label x-axis
ylabel('y(t)') % Label y-axis
title('Time-Frequency Plot') % Give plot a title
grid on % Turn on plot grid
diary off % Turn diary off
guidata(hObject,handles); % code
function fourr(handles)amp=4; t1=str2num(get(handles.t1,'String')); t2=str2num(get(handles.t2,'String')); dt=str2num(get(handles.interval,'String')); t=t1:dt:t2; ValF=str2num(get(handles.startf,'String')); ValF1=str2num(get(handles.endf,'String')); f1=2*pi*ValF; f2=2*pi*ValF1; f= ((f2-f1).*t/(t2-t1)) + f1;y = amp .* sind(f .* t); z=stem(y)'fft(z);stem(f,fft(z));xlabel('Time(sec)')ylabel('FFT')
function ffft_Callback(hObject, eventdata, handles)
fourr(handles); end
Best Answer