Load a saved object which class definition file has been moved

조회 수: 3 (최근 30일)
Pierre Margerit
Pierre Margerit 2019년 12월 3일
I have trouble reloading previously saved objects of a user class after having moved the package containing the class definition.
If i try to be more precise, here is one example:
Let say that i have a class 'myClass' defined in the file '.\+myPkg\+mySubPkg\myClass.m'. I saved one object of this class to the file 'myObject.mat' (using a custom 'saveobj' function, but I don't think that it changes something). Now, for any reasons I want to change the containing folder name '+mySubPkg' to '+mySecondPkg'. If I do this, I won't be able to reload the object in 'myObject.mat' correctly, and MATLAB will issue an error saying: "Warning: Cannot load an object of class 'myClass': Its class cannot be found."
Is there any way to be able to load the object, like from a custom loadobj function or so ? In particular, if 'myClass' inherits from the class 'mySuperClass', which containing folder has not been moved, can I use the loadobj fcn of mySuperClass to re-instanciate an object of 'myClass' from 'myObject.mat' ?

답변 (0개)

카테고리

Help CenterFile Exchange에서 Class File Organization에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by