MATLAB: How to create an object using class name

classoop

In my function, I am getting the class name from an object to create a new one. What is the right syntax to creat the new Object ?
function newObj = createNewObject(obj)
className = class(obj);
newObj = className();
end

Best Answer

function newObj = createNewObject(obj)
newObj = feval( class(obj) );
end