stat_plo.m

来自「Matlab communication toolbox.」· M 代码 · 共 64 行

M
64
字号
function stat_plo(x,a,b)

% STAT_PLOT ... Scatter diagram plotting function.
%
%	STAT_PLOT(X,A,B) operates on the input data array X which must
%		have been generated by the MATLAB function PERSON_DATA.
%		The flags A and B specify which characteristics will
%		be extracted from the array X.	Allowable choices for
%		A and B are:
%
%			'age'           'height'        'weight'
%
%		The corresponding scatter diagram will be then displayed.
%

%	AUTHORS : M. Zeytinoglu & N. W. Ma
%	      Department of Electrical & Computer Engineering
%	      Ryerson Polytechnic University
%	      Toronto, Ontario, CANADA
%
%	DATE	: August 1991.
%	VERSION : 1.0

%===========================================================================
% Modifications history:
% ----------------------
%	o	Tested (and modified) under MATLAB 4.0/4.1 08.16.1993 MZ
%===========================================================================

if strcmp(a,'age')
  yx = x(:,1);
elseif strcmp(a,'height')
  yx = x(:,2);
elseif strcmp(a,'weight')
  yx = x(:,3);
else
  error('Invalid option');
end
if strcmp(b,'age')
  yy = x(:,1);
elseif strcmp(b,'height')
  yy = x(:,2);
elseif strcmp(b,'weight')
  yy = x(:,3);
else
  error('Invalid option');
end
plot(yx,yy,'*'), grid on
if strcmp(a,'age')
  xlabel('age');
elseif strcmp(a,'height')
  xlabel('height [cm]');
else
  xlabel('weight [kg]');
end
if strcmp(b,'age')
  ylabel('age');
elseif strcmp(b,'height')
  ylabel('height [cm]');
else
  ylabel('weight [kg]');
end
hold off

⌨️ 快捷键说明

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