📄 recvar.m
字号:
% *****************************************************************************% RECVAR, A package for new data types in Matlab. % (c) FOA 1998. See the file rvright.m for copyright notice.%% Record variables in RECVAR% --------------------------%% A record variable (called a strucure in Matlab 5) enables the collection% of different Matlab variables that belong to each other in one unit,% a record variable. This concept is usual in programming languages like% Pascal (record) and C/C++ (struct/class) and data bases but did not exist% in Matlab prior to version 5.%% A "record variable" consists of one or more "fields". For example% a record variable 'person1' with the fields 'name' and 'age':%% >> person1 = setr([],'name','Tom');% >> person1 = setr(person1,'age',35);%% Now one can handle the 'person1' with all its fields as one unit.% One can get, for example, the age by:%% >> getr(person1,'age')%% ans =% 35% %% The following functions are currently implemented:%% setr : Creates record variables and creates and changes the % contents of fields.% getr : Gets the contents of fields.% showr : Prints the contents of all fields in a record variable% on the screen. Similar to typing the name of a normal Matlab% variable without a semicolon.% whosr : Like 'whos' but for the fields in a record variable.% recdir : Returns a Matlab matrix with the names of all fields% in a record variable.% existr : Returns true if the specified field exists in the record % variable.% isrecvar: Returns true if the argument is a record variable.% versionr: Returns version info. about the package for record variables.%% tmatvar : A testprogram for testing this package.% % For more information about the functions use 'help' for the corresponding % function.%%Matlab 4:%---------% Allowed operation on record variables is: % assignment '=' of a whole record variable.% It is possible to use record variables as function parameters and as % function return values. Making any other operation except for the functions % below on a record variabl may lead to unpredictable results, including a % system crash.% % Fields can be real or complex full Matlab matrices and Matlab strings.% The possibility to have sparse matrices as fields is not implemented.%% It is possible to use 'save' and 'load' directly with record variables % on a fixed computer system. It is, however, recommended to pick out the % fields with 'getr' and then save the field variables instead of the % record variable. This because matrices may be represented in other % ways on other computer systems or in other releases of Matlab. % With different matrix% representations for 'save' and 'load', the contents in a record variable % will be corrupted and that may lead to unpredictable results, including% a system crash.%% Currently it is not possible to remove a field entirely but this possibility% is planned. Today you can minimize the field size by assigning it an % empty matrix [].%%Matlab 5:%---------% Record variables are implemented using Matlab 5's structures, see [1].%%Other data structures in RECVAR:%--------------------------------% Use 'help multimat' for information about multidimentional matrices, % "multimatrices", (i.e. with more than two indices.).% Use 'help listhelp' for information about the data structure "list".%%References:% [1] "Using Matlab Version 5", The MathWorks, Inc., 1997. % *****************************************************************************% Start : 95xxxx Svante Bj鰎klund (svabj).% Latest change: $Date: 1998/05/12 10:42:08 $ $Author: svabj $.% $Revision: 2.7 $% *****************************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -