-
June 18th, 2017, 08:15 AM
#1
Why is there a data structure in Matlab constructor code below?
I would be glad if someone please help me how to interpret the data structure in Matlab constructor function below.
Many thanks in advance!!!
classdef myClass
*** properties
******* a;
******* d;
******* noInput;
*** end
*** methods
******* function obj=myClass(StructParameters)
*********** if nargin==0
*************** StructParameters.noInput=1;
*********** else
*************** StructParameters.noInput=0;
*********** end
***********
*********** if ~isstruct(StructParameters)
*************** error('Input argument has to be struct.')
*********** else
*************** % load the parameters
*************** F=fields(StructParameters);
*************** for x=1:length(F)
******************* obj.(F{x})=StructParameters.(F{x});
*************** end
*********** end
********************
*********** if ~isfield(StructParameters, 'a')
*************** obj.a=[1 2; 4 5];
*********** end
***
********** if ~isfield(StructParameters, 'd')
*************** obj.d=[0 1; 4 5];
*********** end
******* end
*******
**** end
***
end
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|