Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Matlab Object Oriented Programming - Logical Operators

Status
Not open for further replies.

engineer_eda

Junior Member level 3
Joined
May 14, 2013
Messages
25
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,472
Hello,

Could you please help me how to interpret the logical operators in the following Matlab code?

My questions below. I would be glad if you could explain them.

1-Why there is a structure used in the constructor function below?
2-In the constructor function there is a tilde (~) operator, how do we interpret the usage of this tilde operator here?
3-Is there any other way that can be used to express the same purpose here instead of using tilde?
4-Also could you please help interpreting the usage of isstruct operator in the constructor function?
5-What is the meaning of (~isfield(StructParameters)) logical function?


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

Many thanks in advance!!!!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top