在命令行输入guide,打开matlab的界面向导。
拖入你需要的控件。
在对应的控件callback下写入你的代码。
%----------
1.我不知道如何用call back来让run这个按键调用那个源程序
如果你的源程序是m文件,直接在callback下写上这个m文件名。(m文件放在同一目录下)
如果是exe文件,同样写下文件名,并在exe文件名前加个叹号(注意是英文格式)
2.如何把经过源程序处理过的图像分别显示到以上3个axes中
假设pic1,pic2是你组后处理完成的图像
axes(handles.axes1)
imshow(pic1)
%
axes(handles.axes2)
imshow(pic2)
3.如何把经过源程序计算过的那个数字结果显示到那个TXT
number是你组后的结果数值。
set(handles.text1,'string',num2str(number))
text1是你的那个txt的tag名称。
做了两个程序,一个fig文件,写字板智能输入文字和插入图像,.fig文件给不了你,要怎么给你?我先把程序和截图给你吧。
运行程序后出现的GUI界面
点击按钮后的结果(数字滤波器)
程序如下:
function[db,mag,pha,grd,w]=freqz_m(b,a)
[H,w]=freqz(b,a,1000,'whole')
mag=abs(H)
db=20*log10((mag+eps)/max(mag))
pha=angle(H)
grd=grpdelay(pha)
function varargout = lvboqi(varargin)
gui_Singleton = 1
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @lvboqi_OpeningFcn, ...
'gui_OutputFcn', @lvboqi_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', [])
if nargin &&ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1})
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:})
else
gui_mainfcn(gui_State, varargin{:})
end
function lvboqi_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject
% Update handles structure
guidata(hObject, handles)
% --- Outputs from this function are returned to the command line.
function varargout = lvboqi_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc &&isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white')
end
% --- Executes on button press in batewosiditong.
function batewosiditong_Callback(hObject, eventdata, handles)
% hObject handle to batewosiditong (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%归一化模拟巴特沃斯低通滤波器的设计
Wp=2*pi*1000Ws=2*pi*1500rp=3rs=30%设计滤波器的参数
wp=1ws=Ws/Wp %频带变换得到归一化滤波器
[N,wc]=buttord(wp,ws,rp,rs,'s') %计算滤波器阶数和3dB截止频率
[z,p,k]=buttap(N) %计算归一化滤波器的零极点
[b,a]=zp2tf(z,p,k) %计算归一化滤波器系统函数的系数
w0=0:0.05*pi:2*pi
[h0,w0]=freqs(b,a,w0) %求频率响应
axes(handles.axes1)plot(w0,20*log10(abs(h0)),'k')
title('归一化模拟巴特沃斯低通滤波器')
xlabel('频率f/Hz')ylabel('幅度/dB')grid
% --- Executes on button press in qiebixuefu.
function qiebixuefu_Callback(hObject, eventdata, handles)
% hObject handle to qiebixuefu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA
%归一化模拟且比雪夫I型低通滤波器的设计
Wp=2*pi*1000Ws=2*pi*1500rp=3rs=30%设计滤波器的参数
wp=1ws=Ws/Wp %频带变换得到归一化滤波器
[N,wc]=cheb1ord(wp,ws,rp,rs,'s') %计算滤波器阶数和3dB截止频率
[z,p,k]=cheb1ap(N,rp) %计算归一化滤波器的零极点
[b,a]=zp2tf(z,p,k) %计算归一化滤波器系统函数的系数
w0=0:0.05*pi:2*pi
[h0,w0]=freqs(b,a,w0) %求频率响应
axes(handles.axes2)plot(w0,20*log10(abs(h0)),'k')
title('归一化模拟且比雪夫I型低通滤波器')
xlabel('频率f/Hz')ylabel('幅度/dB')grid
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)