Given a structure, is there a way to create a class in MATLAB? Take for instance
>> p = struct(); p.x = 0; p.y = 0;
>> p
p =
x: 0
y: 0
>> name = 'Point'
name =
Point
What I would like to do, is given a string containing the name of the class and a struct with containing the fields I would like to create a class without having to write a file explicitly writing the definition.
Right now if we use class(p)
we will obtain struct
. What I want to do is create an object of the type Point
so that when I do class(obj)
then I get Point
.
Any ideas how to accomplish this besides writing a file in MATLAB with the class definition and then executing it?