![]() |
SensorPURPOSE
Sensor constructor.
SYNOPSIS
function S=Sensor(varargin)
DESCRIPTION
Sensor constructor. Basic object common for all sensors. The possible parameters are: - Another sensor. - The sensor noise and a file name from where to read the data. - The sensor noise and the cell array of readings. CROSS-REFERENCE INFORMATION
This function calls:
SOURCE CODE
0001 function S=Sensor(varargin) 0002 % Sensor constructor. 0003 % 0004 % Basic object common for all sensors. 0005 % 0006 % The possible parameters are: 0007 % - Another sensor. 0008 % - The sensor noise and a file name from where to read the data. 0009 % - The sensor noise and the cell array of readings. 0010 % 0011 0012 switch nargin 0013 0014 case 1 0015 % Copy constructor 0016 if isa(varargin{1},'Sensor') 0017 S=varargin{1}; 0018 else 0019 error('Sensor copy constructor used with an non-sensor object'); 0020 end 0021 0022 case 2 0023 S.noise=varargin{1}; 0024 0025 if isa(varargin{2},'char') 0026 data=load(varargin{2}); 0027 n=size(data,1); 0028 S.readings=cell(1,n); 0029 for i=1:n 0030 S.readings{i}=data(i,:); 0031 end 0032 else 0033 if isa(varargin{2},'cell'); 0034 S.readings=varargin{2}; 0035 end 0036 end 0037 0038 S=class(S,'Sensor'); 0039 0040 otherwise 0041 error('Wrong number of parameters in Sensor creation'); 0042 end 0043 |