how can i create classes in matlab….please explain using example.
i want to create class operation
in that class there should be 3 functions
add,multiply,minus….
and i want to access it through .m file
i am posting rough c code and i want this to be done in matlab
class operation
{
public:
function add(int a,int b)
{
return(a+b);
}
function minus(int a,int b)
{
return(a-b);
}
}
void main()
{
int a,b;
operaion o;
cout<<o.add(2,4)<<endl;
cout<<o.minus(3,5);
return 0;
}
You can put this as your class in an .m file (e.g. operation.m)
Then you can use it as such:
With that said, I’d highly recommend that you read the matlab documentation for this, as it’s quite thorough. You can start here: http://www.mathworks.com/help/matlab/object-oriented-programming.html