需了解知识
- gui中需要将axes先放入1个panel中,否则后续画多图时曲线可能超出axes范围。
- 若在panel内定义一个axes1,再使用subplot(311)会在当前axes1内绘图,之后会自动删除之前定义的当前axes1,后续无法再调用此axes1。解决办法是H(1)=subplot(311);再用一个句柄记住。
待解决问题
输入任意N,在一个panel内用subplot画N个图。
代码
function xxx_Callback(hObject, eventdata, handles)
num_plot =(ceil(sqrt(handles.N)));% 求subplot的尺寸参数
delete(findobj(handles.pan1, 'Type', 'axes'));% 清空panel 1上所有axes
handles.fig1 = axes('parent',handles.pan1); % pan1内新建一个axes
axes(handles.fig1);
for jj =1:size(sos2,1)
[b,a] = sos2tf(sos2(jj,:));
[hhh,fff]= freqz(b,a,handles.freq,fs); %求频响
subplot(num_plot ,num_plot ,jj);plot(fff,20*log10(hhh));grid on;
set(gca ,'fontsize',4, 'fontname','Times New Roman');
end
guidata(hObject, handles);