⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fftplatform.m

📁 FPGA输出数据的时频域分析GUI界面
💻 M
📖 第 1 页 / 共 2 页
字号:
% hObject    handle to XMax (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 YAuto.
function YAuto_Callback(hObject, eventdata, handles)
% hObject    handle to YAuto (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of YAuto

p=get(handles.Figure,'UserData');

if p==1
    val = get(handles.YAuto,'Value');
    if val == 1
        ud = get(handles.FFTPlatForm,'UserData');
        TData = ud.FData;
        ymin = min(TData);
        ymax = max(TData);
        set(handles.Figure,'YLim',[ymin ymax]);
        set(handles.YMin,'String',num2str(ymin));
        set(handles.YMax,'String',num2str(ymax));
    else
        YMin_Callback;
        YMax_Callback;
    end
    % Set the Auto Parameter Enable on
    set(handles.YAuto,'Enable','off');
else 
    if p==2
        val = get(handles.YAuto,'Value');
        if val == 1
            ud = get(handles.FFTPlatForm,'UserData');
            Power = ud.PData;
            ymin = min(Power);
            ymax = max(Power);
            set(handles.Figure,'YLim',[ymin ymax]);
            set(handles.YMin,'String',num2str(ymin));
            set(handles.YMax,'String',num2str(ymax));
        else
            YMin_Callback;
            YMax_Callback;
        end
        % Set the Auto Parameter Enable on
        set(handles.YAuto,'Enable','off');
    end
    if p==3
        val = get(handles.YAuto,'Value');
        if val == 1
            ud = get(handles.FFTPlatForm,'UserData');
            Power_wrap = ud.PData_wrap;
            ymin = min(Power_wrap);
            ymax = max(Power_wrap);
            set(handles.Figure,'YLim',[ymin ymax]);
            set(handles.YMin,'String',num2str(ymin));
            set(handles.YMax,'String',num2str(ymax));
        else
            YMin_Callback;
            YMax_Callback;
        end
        % Set the Auto Parameter Enable on
        set(handles.YAuto,'Enable','off');
    end
end


function YMin_Callback(hObject, eventdata, handles)
% hObject    handle to YMin (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 YMin as text
%        str2double(get(hObject,'String')) returns contents of YMin as a double

ymin = str2double(get(handles.YMin,'String'));
y = get(handles.Figure,'YLim');
ymax = y(2);
set(handles.Figure,'YLim',[ymin ymax]);
set(handles.YAuto,'Value',0);
% Set the Auto Parameter Enable on
set(handles.YAuto,'Enable','on');



% --- Executes during object creation, after setting all properties.
function YMin_CreateFcn(hObject, eventdata, handles)
% hObject    handle to YMin (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



function YMax_Callback(hObject, eventdata, handles)
% hObject    handle to YMax (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 YMax as text
%        str2double(get(hObject,'String')) returns contents of YMax as a double

ymax = str2double(get(handles.YMax,'String'));
y = get(handles.Figure,'YLim');
ymin = y(1);
set(handles.Figure,'YLim',[ymin ymax]);
set(handles.YAuto,'Value',0);
% Set the Auto Parameter Enable on
set(handles.YAuto,'Enable','on');


% --- Executes during object creation, after setting all properties.
function YMax_CreateFcn(hObject, eventdata, handles)
% hObject    handle to YMax (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





function InputData_Callback(hObject, eventdata, handles)
% hObject    handle to InputData (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 InputData as text
%        str2double(get(hObject,'String')) returns contents of InputData as a double


% --- Executes during object creation, after setting all properties.
function InputData_CreateFcn(hObject, eventdata, handles)
% hObject    handle to InputData (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 during object creation, after setting all properties.
function WindowSelection_CreateFcn(hObject, eventdata, handles)
% hObject    handle to WindowSelection (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu 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 selection change in VariableList.
function VariableList_Callback(hObject, eventdata, handles)
% hObject    handle to VariableList (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns VariableList contents as cell array
%        contents{get(hObject,'Value')} returns selected item from VariableList


% --- Executes during object creation, after setting all properties.
function VariableList_CreateFcn(hObject, eventdata, handles)
% hObject    handle to VariableList (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox 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 Plot.
function Plot_Callback(hObject, eventdata, handles)
% hObject    handle to Plot (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get the float data and the sample frequency
ud = get(handles.FFTPlatForm,'UserData');
TData = ud.FData;
Fs = ud.Fs;

val = get(handles.VariableList,'Value');
switch val
    case 1,
        % Plot the time domain figure
        t = 0:1/Fs:(length(TData)-1)/Fs;
        axes(handles.Figure);
        stairs(t,TData);
        title('Time Domain Figure');
        xlabel('t/(ms)')
        ylabel('Magnitude')
        zoom on;grid on;axis tight;hold off;% creat imag plot
        
        % Set the Notes frame
        set(handles.Notes,'ForegroundColor','black');
        handles.str=get(handles.Notes,'String');
        str = '->> Time domain figure ploting has been done.';
        handles.str=[handles.str;str];
        set(handles.Notes,'String',handles.str);
        
        % Set the axes control frame
        xmin = num2str(0);
        xmax = num2str(((length(TData)-1)/Fs));
        set(handles.XMin,'String',xmin);
        set(handles.XMax,'String',xmax);
        ymin = num2str(min(TData));
        ymax = num2str(max(TData));
        set(handles.YMin,'String',ymin);
        set(handles.YMax,'String',ymax);
        
        % Set the Auto Paremeter Value
        set(handles.XAuto,'Value',1);
        set(handles.YAuto,'Value',1);
        
        set(handles.Figure,'UserData',1);
    case 2,
        % Get the float data and the sample frequency
        ud = get(handles.FFTPlatForm,'UserData');
        SData = ud.SData;
        plotstring='b.';
        
        maxAll = max(max(abs(SData)));
        [len_SD, wid_SD]=size(SData);
        
        if wid_SD == 1
            axes(handles.Figure)
            plot(SData, zeros(1,len_SD), plotstring);
        elseif wid_SD == 2
            axes(handles.Figure)
            plot(SData(:,1), SData(:,2), plotstring);
        end

%         axis([-eps eps -eps eps]);
%         axo = axis;
%         limFact = 1.07;
%         limits = max(max(abs(axo)),maxAll*limFact);
%         axis equal;
%         axis([-limits limits -limits limits]);
        ylabel('Quadrature')
        xlabel('In-Phase')
        title('Scatter plot')
        zoom on;grid on;axis tight;hold off;% creat imag plot
    case 3,
    case 4,
        % Get the FFT data and the f factor
        ud = get(handles.FFTPlatForm,'UserData');
        Power = ud.PData;
        Fs = ud.Fs;
        f = ud.f;
        
        % Plot the FFT Power figure
        axes(handles.Figure)
        plot(f,Power);
        grid on
        title('FFT Power Magnitude Spectrum')
        xlabel('f/(kHz)')
        ylabel('Magnitude in dBm')
        zoom on;grid on;axis tight;hold off;% creat imag plot
        set(handles.Notes,'ForegroundColor','black');
        handles.str=get(handles.Notes,'String');
        str = '->> FFT Power figure ploting has been done.';
        handles.str=[handles.str;str];
        set(handles.Notes,'String',handles.str);
        
        % Set the axes control frame
        xmin = num2str(-Fs/2);
        xmax = num2str(Fs/2);
        set(handles.XMin,'String',xmin);
        set(handles.XMax,'String',xmax);
        ymin = num2str(min(Power));
        ymax = num2str(max(Power));
        set(handles.YMin,'String',ymin);
        set(handles.YMax,'String',ymax);
        
        % Set the Auto State
        set(handles.XAuto,'Value',1);
        set(handles.YAuto,'Value',1);
        
        set(handles.Figure,'UserData',2);
        
        % Set EnvelopePlot Push Button enable on
%         set(handles.EnvelopePlot,'Enable','on');
    case 5,
        % Get the power data
        ud = get(handles.FFTPlatForm,'UserData');
        Power = ud.PData;
        Fs=ud.Fs;
        
        axes(handles.Figure)
        N=64;
        [Power_wrap t]=my_wrap(Power,Fs*1e3,N);
        
        % Set FFTFPlot UserData the Power data
        ud.PData_wrap = Power_wrap;
        set(handles.FFTPlatForm,'UserData',ud);
        
        plot(t/1e3,Power_wrap);
        grid on
        title('FFT Power')
        xlabel('f/(kHz)')
        ylabel('Magnitude in dBm')
        zoom on;grid on;axis tight;hold off;% creat imag plot
        set(handles.Notes,'ForegroundColor','black');
        handles.str=get(handles.Notes,'String');
        str = '->> FFT Power figure envelop ploting has been done.';
        handles.str=[handles.str;str];
        set(handles.Notes,'String',handles.str);
        
        % Set the axes control frame
        xmin = num2str(-Fs/2);
        xmax = num2str(Fs/2);
        set(handles.XMin,'String',xmin);
        set(handles.XMax,'String',xmax);
        ymin = num2str(min(Power_wrap));
        ymax = num2str(max(Power_wrap));
        set(handles.YMin,'String',ymin);
        set(handles.YMax,'String',ymax);
        
        % Set the Auto State
        set(handles.XAuto,'Value',1);
        set(handles.YAuto,'Value',1);
        set(handles.Figure,'UserData',3);
end
        









function IQPE_Callback(hObject, eventdata, handles)
% hObject    handle to IQPE (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 IQPE as text
%        str2double(get(hObject,'String')) returns contents of IQPE as a double


% --- Executes during object creation, after setting all properties.
function IQPE_CreateFcn(hObject, eventdata, handles)
% hObject    handle to IQPE (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



function SNR_Callback(hObject, eventdata, handles)
% hObject    handle to SNR (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 SNR as text
%        str2double(get(hObject,'String')) returns contents of SNR as a double


% --- Executes during object creation, after setting all properties.
function SNR_CreateFcn(hObject, eventdata, handles)
% hObject    handle to SNR (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



function EVM_Callback(hObject, eventdata, handles)
% hObject    handle to EVM (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 EVM as text
%        str2double(get(hObject,'String')) returns contents of EVM as a double


% --- Executes during object creation, after setting all properties.
function EVM_CreateFcn(hObject, eventdata, handles)
% hObject    handle to EVM (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 Help.
function Help_Callback(hObject, eventdata, handles)
% hObject    handle to Help (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -