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

📄 ryanpl.m

📁 本实验的内容是无线楼宇数据传输仿真
💻 M
字号:
function varargout = ryanpl(varargin)
% RYANPL M-file for ryanpl.fig
%      RYANPL, by itself, creates a new RYANPL or raises the existing
%      singleton*.
%
%      H = RYANPL returns the handle to a new RYANPL or the handle to
%      the existing singleton*.
%
%      RYANPL('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in RYANPL.M with the given input arguments.
%
%      RYANPL('Property','Value',...) creates a new RYANPL or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before ryanpl_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to ryanpl_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Copyright 2002-2003 The MathWorks, Inc.

% Edit the above text to modify the response to help ryanpl

% Last Modified by GUIDE v2.5 14-May-2006 17:37:16

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @ryanpl_OpeningFcn, ...
                   'gui_OutputFcn',  @ryanpl_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 ryanpl is made visible.
function ryanpl_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 ryanpl (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = ryanpl_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;

% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit3 (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

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

s1 = str2double(get(hObject, 'String'));
if isnan(s1)
    set(hObject, 'String', 0);
    errordlg('Input must be a number','Error');
end

if s1<0
    errordlg('发端和收端的房间差必须大于0','Error');
end;

% Save the new density value
handles.metricdata.s1 = s1;
guidata(hObject,handles)




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

s2 = str2double(get(hObject, 'String'));
if isnan(s2)
    set(hObject, 'String', 0);
    errordlg('Input must be a number','Error');
end

if s2<0
    errordlg('发端和收端的房间差必须大于0','Error');
end;

% Save the new density value
handles.metricdata.s2 = s2;
guidata(hObject,handles)

% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4 (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



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

s3 = str2double(get(hObject, 'String'));
if isnan(s3)
    set(hObject, 'String', 0);
    errordlg('Input must be a number','Error');
end

if s3<0
    errordlg('发端和收端的楼层差必须在0到3之间','Error');
elseif s3>3
    errordlg('发端和收端的楼层差必须在0到3之间','Error');
end;

% Save the new density value
handles.metricdata.s3 = s3;
guidata(hObject,handles)

% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit5 (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)



wh=2.5;              %每个房间的宽度(m)
dh=3.5;              %每个房间的长度(纵深)(m)
ht=3;              %每个房间的高度(m)

pl_d0=31.7;        %从发端到参考距离d0的路径衰减,d0=1 m
faf=0;             %楼层间的路径衰减值(dB)
l=0.32786882459;   %波长,l=c/f=300M (m/s) /914M (Hz) =0.328227571116 m
af=2.38;           %每层混凝土墙的路径衰减值(dB)

s=[handles.metricdata.s1  handles.metricdata.s2  handles.metricdata.s3]; %输入矩阵
w=sqrt((s(1)*wh)*(s(1)*wh)+(s(2)*dh)*(s(2)*dh));  %w为两点间水平纵深方向的直线距离
h=s(3)*ht;         %h为两点间垂直方向的直线距离
dx=s(1)+s(2);      %dx为两点间水平方向相隔的混凝土墙的数目
dy=s(3);           %dy为两点间垂直方向相隔的楼板的数目

if dx==0
    pl_dx=0;
else pl_dx=20.0*log(4*pi*w/l)/log(10)+dx*af;  %水平方向传播的路径衰减(dB)
end;

if dy==1   %垂直方向相隔的楼板数目不同,对应的参数n和FAF不同
    n=4.19;
    faf=12.9;
elseif dy==2
    n=5.04;
    faf=18.7;
elseif dy==3
    n=5.22;
    faf=24.4;
end;

if dy==0
    pl_dy=0;
else pl_dy=pl_d0+10.0*n*log(h)/log(10)+faf;  %垂直方向传播的路径衰减(dB)
end;

pl_d=pl_dx+pl_dy;                            %总的路径衰减(dB)

set(handles.pl, 'String', pl_d);             %返回到fig中

if pl_d<=110                                 %判断得出的路径衰减值是否在允许的范围内
    str='路径衰减处在允许的范围内,能进行数据传输';
else str='路径衰减超出允许的范围,不能进行数据传输';
end;

set(handles.text2, 'String', str);           %返回到fig中

⌨️ 快捷键说明

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