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

📄 icdtool.m

📁 实现mimo+ofdm的功能
💻 M
📖 第 1 页 / 共 2 页
字号:
function varargout = icdtool(varargin)
%ICDTOOL - Individual Channel Design utility for 2x2 MIMO systems
%
% Syntax:
%    icdtool(G) - Starts icdtool for G, where G is a transfer function matrix
%
% Example: 
%    g11=tf(2,[1 3 2]);
%    g12=tf(-2,[1 1]);
%    g21=tf(-1,[1 2 1]);
%    g22=tf(6,[1 5 6]);
%    G=[g11 g12; g21 g22];
%
% Other m-files required: nyqmimo
%
% Author: Oskar Vivero Osornio
% email: oskar.vivero@gmail.com
% Created: February 2006; 
% Last revision: 12-April-2006;

% May be distributed freely for non-commercial use, 
% but please leave the above info unchanged, for
% credit and feedback purposes

% Last Modified by GUIDE v2.5 20-Apr-2006 00:42:51

%------------- BEGIN CODE --------------
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @icdtool_OpeningFcn, ...
                   'gui_OutputFcn',  @icdtool_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
% End initialization code - DO NOT EDIT


% --- Executes just before icdtool is made visible.
function icdtool_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to icdtool (see VARARGIN)

% Determining Input
ni=nargin;

switch ni
    case 4
        %Input is a matrix transfer function 
        G=varargin{1};
end


g11=G(1,1);
g12=G(1,2);
g21=G(2,1);
g22=G(2,2);
gamma=minreal((g12*g21)/(g11*g22));

setappdata(0,'hMainGui',gcf);
setappdata(gcf,'G',G);
setappdata(gcf,'gamma',gamma);

% Choose default command line output for icdtool
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes icdtool wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = icdtool_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;



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


% --- Executes during object creation, after setting all properties.
function gain_K1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to gain_K1 (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 poles_K1_Callback(hObject, eventdata, handles)
% hObject    handle to poles_K1 (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 poles_K1 as text
%        str2double(get(hObject,'String')) returns contents of poles_K1 as a double


% --- Executes during object creation, after setting all properties.
function poles_K1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to poles_K1 (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 zeros_K1_Callback(hObject, eventdata, handles)
% hObject    handle to zeros_K1 (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 zeros_K1 as text
%        str2double(get(hObject,'String')) returns contents of zeros_K1 as a double


% --- Executes during object creation, after setting all properties.
function zeros_K1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to zeros_K1 (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 gain_K2_Callback(hObject, eventdata, handles)
% hObject    handle to gain_K2 (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 gain_K2 as text
%        str2double(get(hObject,'String')) returns contents of gain_K2 as a double


% --- Executes during object creation, after setting all properties.
function gain_K2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to gain_K2 (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 poles_K2_Callback(hObject, eventdata, handles)
% hObject    handle to poles_K2 (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 poles_K2 as text
%        str2double(get(hObject,'String')) returns contents of poles_K2 as a double


% --- Executes during object creation, after setting all properties.
function poles_K2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to poles_K2 (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 zeros_K2_Callback(hObject, eventdata, handles)
% hObject    handle to zeros_K2 (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 zeros_K2 as text
%        str2double(get(hObject,'String')) returns contents of zeros_K2 as a double


% --- Executes during object creation, after setting all properties.
function zeros_K2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to zeros_K2 (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 selection change in popupmenu_C1.
function popupmenu_C1_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu_C1 (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 popupmenu_C1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu_C1

% Get user input from GUI
% System data
hMainGui = getappdata(0,'hMainGui');
G = getappdata(hMainGui,'G');
gamma = getappdata(hMainGui,'gamma');
g11 = G(1,1);
g12 = G(1,2);
g21 = G(2,1);
g22 = G(2,2);

val = get(hObject,'Value');
str = get(hObject, 'String');

figure(1)
switch str{val};
    case 'Nyquist of Gamma' % User selects peaks

        % Status window
        [num11,den11]=tfdata(g11,'v');
        [num22,den22]=tfdata(g22,'v');
        zeros11=roots(num11);
        zeros22=roots(num22);
        RHPP11=0;
        RHPP22=0;
        for i=1:length(zeros11)
            if sign(real(zeros(i)))==1
                RHPP11=RHPP11+1;
            end
        end

        for i=1:length(zeros22)
            if sign(real(zeros22(i)))==1
                RHPP22=RHPP22+1;
            end
        end
        s1=sprintf('%-d RHPP in g11',RHPP11);
        s2=sprintf('%-d RHPP in g22',RHPP22);
        vars{1}='RHPP of Gamma';
        vars{2}=s1;
        vars{3}=s2;
        set(handles.status_window,'String',vars)
        
        % Plot
        syms p
        g=tf2sym(gamma);
        nyqmimo(gamma);
        title('Nyquist Diagram of Gamma')

    case 'Bode k1*g11' % User selects membrane
        k1=getappdata(hMainGui,'k1');
        margin(k1*g11);

    case 'Bode h1'
        h1=getappdata(hMainGui,'h1');

        % Status Window
        [num,den]=tfdata(h1,'v');
        den=roots(den);
        RHPP=0;
        for i=1:length(den)
            if sign(real(den))==1
                RHPP=RHPP+1;
            end
        end
        vars{1}=sprintf('%-d RHPP in h1',RHPP);
        set(handles.status_window,'String',vars)

⌨️ 快捷键说明

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