distance.m

来自「一个关于仿真的程序」· M 代码 · 共 28 行

M
28
字号
% Program 6-3
% distance.m
%
% The calculation of distance between access point and access terminal.
%
% Input arguments
%   bstn : coordinate of access point(x,y,z)
%   mstn : coordinate of access terminals(x,y,z) (mstn is vector or matrix)
%   stp  : scale (if stp is omitted, scl=1.)
%
% Output argument
%   d    : distance
%
% Programmed by M.Okita
% Checked by H.Harada
%

function [d] = distance(bstn, mstn, scl)

if nargin < 3                                                       % stp is omitted
    scl = 1;
end

[v,h] = size(mstn);
d     = sqrt(sum(rot90(((repmat(bstn,v,1)-mstn)*scl).^2)));

%%%%%%%%%%%%%%%%%%%%%% end of file %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

⌨️ 快捷键说明

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