📄 bysj.m
字号:
%一阶均衡曲线相关 %获取参数----从slider_bar的value属性直接读出 cf1_temp = get(findobj('tag','slider_cf1'),'value'); %为什么要这样做? 因为slider_bar只能处理整数类型,最大值是2^31=2147483647=2.14GHz 太小了 cf1 = cf1_temp * 1000; sj1 = get(findobj('tag','slider_att1'),'value'); cf2_temp = get(findobj('tag','slider_cf2'),'value'); %为什么要这样做? 因为slider_bar只能处理整数类型,最大值是2^31=2147483647=2.14GHz 太小了 cf2 = cf2_temp * 1000; sj2 = get(findobj('tag','slider_att2'),'value'); %一阶均衡的衰减器曲线参数计算 f_out = xstart:(xend-xstart)/200:xend; %第一阶均衡的计算 a1 = 10^(sj1/10); fenzi1 = 1/a1 + (f_out/cf1).*(f_out/cf1); fenmu1 = a1 + (f_out/cf1).*(f_out/cf1); amp_out_1 = 10*log10(fenzi1./fenmu1); %第二阶均衡的计算 a2 = 10^(sj2/10); fenzi2 = 1/a2 + (f_out/cf2).*(f_out/cf2); fenmu2 = a2 + (f_out/cf2).*(f_out/cf2); amp_out_2 = 10*log10(fenzi2./fenmu2); %插值曲线相关 interp1_x_string = get(findobj('tag','edit_interp1_x'),'string'); interp1_x_array = str2num(interp1_x_string); interp1_y_string = get(findobj('tag','edit_interp1_y'),'string'); interp1_y_array = str2num(interp1_y_string); %插值的范围就是【xstart xend ystart yend】 %开始插值 interp1_x = xstart:((xend - xstart)/200):xend; interp1_y = interp1(interp1_x_array,interp1_y_array,interp1_x,'spline'); %这里应该可选择插值方式 就用spline方式即可 %二者加和曲线 amp_out_all_2 = amp_out_1 + amp_out_2 + interp1_y; %开始画图 这里的坐标系在滑动slider_bar的时候触发 plot(f_out,interp1_y,'m') hold on; plot(f_out,amp_out_1,'b') hold on; plot(f_out,amp_out_2,'c') hold on; plot(f_out,amp_out_all_2,'r') hold on; axis([xstart,xend,ystart,yend]) xlabel('频率'),ylabel('衰减') title('二级均衡结果 幅频特性曲线 线性坐标系') grid onend%绘制均衡结果二阶相频 改变slider_bar之后就能够重新计算并绘图一次function [f_out,phase_out_all_2,phase_out_1,phase_out_2] = painting_xiangpin_all_2()global m_phase_array m_add_state phase_out_1 phase_out_2if m_add_state==1 %基本参数读取 xstart = str2num(get(findobj('Tag','edit_xstart'),'string')); xend = str2num(get(findobj('Tag','edit_xend'),'string')); %二阶均衡曲线相关 %获取参数----从slider_bar的value属性直接读出 %一阶均衡已经由前面的代替了 cf2_temp = get(findobj('tag','slider_cf2'),'value'); %为什么要这样做? 因为slider_bar只能处理整数类型,最大值是2^31=2147483647=2.14GHz 太小了 cf2 = cf2_temp * 1000; sj2 = get(findobj('tag','slider_att2'),'value'); %二阶均衡的衰减器相频参数计算 f_out = xstart:(xend-xstart)/200:xend; %第一阶 phase_out_1 = m_phase_array; %第二阶 a2 = 10^(sj2/10); fenzi2 = sqrt(a2)*(a2-1); fenmu2 = a2.*(f_out ./ cf2 + cf2 ./ f_out); theta2 = atan(fenzi2./fenmu2); phase_out_2 = theta2.* 360/(2*pi); %加和得到总的相移 phase_out_all_2 = phase_out_1 + phase_out_2; %绘图 plot(f_out,phase_out_1,'b') hold on; plot(f_out,phase_out_2,'c') hold on; plot(f_out,phase_out_all_2,'r') hold on; xlabel('频率'),ylabel('角度') title('累加均衡结果 相频特性曲线 线性坐标系') grid on %%%%%%%%%%%将相位最大值的X坐标和Y坐标显示与phase_all max中 [y_all_max,count] = max(phase_out_all_2); x_phase_max = f_out(count); str_x = 'x = '; set(findobj('tag','text_phaseall_x'),'string',[str_x,sprintf('%6.4g\',x_phase_max)]); str_y = 'y = '; set(findobj('tag','text_phaseall_y'),'string',[str_y,sprintf('%6.4g\',y_all_max)]); %%%%%%%%%%%将相位最大值的X坐标和Y坐标显示与phase 1 max中 set(findobj('tag','text_phase1_x'),'string','invalid'); set(findobj('tag','text_phase1_y'),'string','invalid'); %%%%%%%%%%%将相位最大值的X坐标和Y坐标显示与phase 2 max中 str_x = 'x = '; set(findobj('tag','text_phase2_x'),'string',[str_x,sprintf('%6.4g\',cf2)]); y_2_max = max(phase_out_2); str_y = 'y = '; set(findobj('tag','text_phase2_y'),'string',[str_y,sprintf('%6.4g\',y_2_max)]);else %基本参数读取 xstart = str2num(get(findobj('Tag','edit_xstart'),'string')); xend = str2num(get(findobj('Tag','edit_xend'),'string')); %二阶均衡曲线相关 %获取参数----从slider_bar的value属性直接读出 cf1_temp = get(findobj('tag','slider_cf1'),'value'); %为什么要这样做? 因为slider_bar只能处理整数类型,最大值是2^31=2147483647=2.14GHz 太小了 cf1 = cf1_temp * 1000; sj1 = get(findobj('tag','slider_att1'),'value'); cf2_temp = get(findobj('tag','slider_cf2'),'value'); %为什么要这样做? 因为slider_bar只能处理整数类型,最大值是2^31=2147483647=2.14GHz 太小了 cf2 = cf2_temp * 1000; sj2 = get(findobj('tag','slider_att2'),'value'); %二阶均衡的衰减器相频参数计算 f_out = xstart:(xend-xstart)/200:xend; %第一阶 a1 = 10^(sj1/10); fenzi1 = sqrt(a1)*(a1-1); fenmu1 = a1.*(f_out ./ cf1 + cf1 ./ f_out); theta1 = atan(fenzi1./fenmu1); phase_out_1 = theta1.* 360/(2*pi); %第二阶 a2 = 10^(sj2/10); fenzi2 = sqrt(a2)*(a2-1); fenmu2 = a2.*(f_out ./ cf2 + cf2 ./ f_out); theta2 = atan(fenzi2./fenmu2); phase_out_2 = theta2.* 360/(2*pi); %加和得到总的相移 phase_out_all_2 = phase_out_1 + phase_out_2; %绘图 plot(f_out,phase_out_1,'b') hold on; plot(f_out,phase_out_2,'c') hold on; plot(f_out,phase_out_all_2,'r') hold on; xlabel('频率'),ylabel('角度') title('二级均衡结果 相频特性曲线 线性坐标系') grid on %%%%%%%%%%%将相位最大值的X坐标和Y坐标显示与phase_all max中 [y_all_max,count] = max(phase_out_all_2); x_phase_max = f_out(count); str_x = 'x = '; set(findobj('tag','text_phaseall_x'),'string',[str_x,sprintf('%6.4g\',x_phase_max)]); str_y = 'y = '; set(findobj('tag','text_phaseall_y'),'string',[str_y,sprintf('%6.4g\',y_all_max)]); %%%%%%%%%%%将相位最大值的X坐标和Y坐标显示与phase 1 max中 str_x = 'x = '; set(findobj('tag','text_phase1_x'),'string',[str_x,sprintf('%6.4g\',cf1)]); y_1_max = max(phase_out_1); str_y = 'y = '; set(findobj('tag','text_phase1_y'),'string',[str_y,sprintf('%6.4g\',y_1_max)]); %%%%%%%%%%%将相位最大值的X坐标和Y坐标显示与phase 2 max中 str_x = 'x = '; set(findobj('tag','text_phase2_x'),'string',[str_x,sprintf('%6.4g\',cf2)]); y_2_max = max(phase_out_2); str_y = 'y = '; set(findobj('tag','text_phase2_y'),'string',[str_y,sprintf('%6.4g\',y_2_max)]);end % --- Executes on button press in pb_help.function pb_help_Callback(hObject, eventdata, handles)% hObject handle to pb_help (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)path = 'C:\Documents and Settings\Administrator\桌面\bysj help\首页.htm';web(path);function edit_interp1_x_Callback(hObject, eventdata, handles)% hObject handle to edit_interp1_x (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 edit_interp1_x as text_phase_diff% str2double(get(hObject,'String')) returns contents of edit_interp1_x as a double%取edit_box里面输入的坐标来进行插值,恢复出信道曲线% --- Executes during object creation, after setting all properties.function edit_interp1_x_CreateFcn(hObject, eventdata, handles)% hObject handle to edit_interp1_x (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 pb_interp1.function pb_interp1_Callback(hObject, eventdata, handles)% hObject handle to pb_interp1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%这是一个示例程序% t = 500:100:3000;% p = [17.85 17.55 17.24 16.91 16.52...% 16.14 15.75 15.35 14.93 14.37...% 13.87 13.39 12.64 12.17 11.66...% 10.84 10.35 9.63 8.61 8.03...% 7.75 7.11 6.85 6.38 5.55 ...% 5.05];% x = 500:10:3000;% y = interp1(t,p,x,'spline');% plot(t,p,'o',x,y)global interp1_y%这里开始编写global xstart xend ystart yendinterp1_x_string = get(findobj('tag','edit_interp1_x'),'string');interp1_x_array = str2num(interp1_x_string);interp1_y_string = get(findobj('tag','edit_interp1_y'),'string');interp1_y_array = str2num(interp1_y_string);%这里要选择插值的范围 应该从输入的范围框里面选取interp1_x_start = str2num(get(findobj('tag','edit_xstart'),'string'));interp1_x_end = str2num(get(findobj('tag','edit_xend'),'string'));%开始插值interp1_x = interp1_x_start:((interp1_x_end - interp1_x_start)/200):interp1_x_end;interp1_y = interp1(interp1_x_array,interp1_y_array,interp1_x,'spline'); %这里应该可选择插值方式 就用spline方式即可%开始画图axes(handles.axes_fupin); %选择画图区域 %这里的xstart xend ystart yend都是已经引用了的 %选择坐标系 -- 这里只有可能是线性坐标系 plot(interp1_x_array,interp1_y_array,'*',interp1_x,interp1_y) axis([xstart,xend,ystart,yend]) hold onfunction edit_interp1_y_Callback(hObject, eventdata, handles)% hObject handle to edit_interp1_y (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 edit_interp1_y as text_phase_diff% str2double(get(hObject,'String')) returns contents of edit_interp1_y as a double% --- Executes during object creation, after setting all properties.function edit_interp1_y_CreateFcn(hObject, eventdata, handles)% hObject handle to edit_interp1_y (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 slider movement.function slider_cf1_Callback(hObject, eventdata, handles)% hObject handle to slider_cf1 (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,'Value') returns position of slider% get(hObject,'Min') and get(hObject,'Max') to determine range of slider% slider_cf1_position = get(hObject,'value');%直接返回一个真实的值% set(findobj('tag','slider_cf1_value'),'string',num2str(slider_cf1_position)); %slider_bar的value返回的是一个double的数值set(findobj('tag','slider_cf1_value'),'string',num2str(get(hObject,'value')));global eelif eel == 1 axes(handles.axes_fupin) cla reset; painting_fupin_all_1(); axes(handles.axes_xiangpin)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -