您好,高手,请教您一个问题:我现在要实现,给一个edit里输入采样频率,一个edit里输入才样点数,用wavread读入一个音频文件对其进行fft变换,吧频谱由一个坐标系输出来,请问我的各个控件下的回调函数应该怎么写,非常感谢!
请高手们,详细说明下,在下是初学者,多多包涵!
可以参考下
% --- Executes on button press in fft.
function fft_Callback(hObject, eventdata, handles)
global pathname filename sf nfft outfile H1 H2;
fid=fopen([pathname filename],'r');
x=fscanf(fid,'%f',[1,inf]); %按行读入原始信号数据
%FFT变换
nt=length(x);
h=findobj('Tag','cypl');
sf=str2double(get(h,'string'));
h=findobj('Tag','nfftcd');
nfft=str2double(get(h,'string'));
y=fft(x);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%绘制输入曲线图形
t=0:1/sf:100/sf;
plot(H1,t,x(1:101));
xlabel('时间(s)');
ylabel('幅值');
title('输入数据的时程曲线图')
grid on;
%绘制幅频曲线图
f=0:sf/nfft:(nt-1)*sf/nfft;
plot(H2,f,abs(y));
axis([0,(nt-1)*sf/(nfft*2),3*min(y)/2,3*max(y)/2])
xlabel('频率(Hz)');
ylabel('幅值');
title('信号频谱图');
outfile=y;
grid on
%grid on;
%h = findobj('tag',axes1)
% hObject handle to fft (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
多看看帮助,那里面都有例子,比到这里问要好
% --- Executes on button press in fft.
function fft_Callback(hObject, eventdata, handles)
global pathname filename sf nfft outfile H1 H2;
fid=fopen([pathname filename],'r');
x=fscanf(fid,'%f',[1,inf]); %按行读入原始信号数据
%FFT变换
nt=length(x);
h=findobj('Tag','cypl');
sf=str2double(get(h,'string'));
h=findobj('Tag','nfftcd');
nfft=str2double(get(h,'string'));
y=fft(x);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%绘制输入曲线图形
t=0:1/sf:100/sf;
plot(H1,t,x(1:101));
xlabel('时间(s)');
ylabel('幅值');
title('输入数据的时程曲线图')
grid on;
%绘制幅频曲线图
f=0:sf/nfft:(nt-1)*sf/nfft;
plot(H2,f,abs(y));
axis([0,(nt-1)*sf/(nfft*2),3*min(y)/2,3*max(y)/2])
xlabel('频率(Hz)');
ylabel('幅值');
title('信号频谱图');
outfile=y;
grid on
%grid on;
%h = findobj('tag',axes1)
% hObject handle to fft (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
多看看帮助,那里面都有例子,比到这里问要好
温馨提示:答案为网友推荐,仅供参考
第1个回答 2009-05-18
你需要了解function edit1_Callback(hObject, eventdata, handles)里面对应的三个参数分别代表什么意思。
输入的值是存在hobject里面的,在把两个edit返回的值放入fft变换就可以了
输入的值是存在hobject里面的,在把两个edit返回的值放入fft变换就可以了