MATLAB Documentation for OOP
(For reference by students)


 

OBJECTS
Definition A software construct that encapsulates behaviors and data
 
Example
function acct = BankAccount(data)
if nargin == 0                           
   acct.balance = 0;
   acct = class(acct,'BankAccount');
elseif isa(data, 'BankAccount')          
   acct = data;
else
   acct.balance = data;
   acct = class(acct,'BankAccount');
end
 

In the command window, typing

ba = BankAccount

would create the object 'ba' of class BankAccount with all the methods associated with it.

 


Got comments\feedback\suggestions\complaints\anything whatsoever? Shoot the webmaster an email!

Website created & maintained by Shardul Bhatia and Wen Eu Cheah