I am running into an enraged problem with Matlab, and apparently the same problem did not help me, bad luck To I'm sorry that this question is too long - you need a lot of information to reproduce the problem (I tried to trim it as much as possible ...)
The problem is: Regardless of what I do, when I have used a class, I can not "forget the matlab". In the latter case, the error message is:
WARNING: Class file changed to 'myClass': the value used is constantly visible, and editing will not be "stick" for class definition. is; But the change can not be implemented because the object based on the old class file still exists. If you use those items, you can get unexpected results. You can use the 'clear' command to remove those items. See 'Explanation' for information on how to remove those objects.
Send me that message
& gt; & Gt; Clear all & gt; & Gt; Clear work & gt; & Gt; Clear ans
Regardless of its efforts to clarify it in any way, the definition of class is constant. To make matters worse, when I am modifying the value of an example of a class, clean it, the value is not "forgotten" in some way. For example, here is the source code of
myClass :
% Definition of a simple class which shows the problem which I redefined without any classes To do% Matlab classdef myClass & lt; Handling the pioneers of property = {'none'}; NumPre = {1}; Value = 1; End methods function obj = myClass (pre, number, wall)% constructor if nargin> 0 obj.precursors = East; Obj.numPre = num; Obj.value = val; End end function V = sumVal (obj)% the sum of the value of all the predecessor n = numel (obj.precursors); V = 0; For IE = 1: N PC = OBJ. Tractors (ii); If ISA (PC, 'MyClus') if Ii == 1 V = 0; End v = v + sumVal (pc) * obj.numPre {ii}; Else v = obj.value; End end end end% can be the following named example: Counting Dada ({'none'}}, 1, 1 father ({myClass.grandpa}, {3}, -1) son ({myClass.father}, {2}, -1) End end
In a new example, Matlab, I do the following:
& gt; & Gt; Sons = myClass.son; & Gt; & Gt; SumVal (sons) ans = 6> gt; & Gt; Grandfather = myClass.grandpa; & Gt; & Gt; Grandpa.value = 5; & Gt; & Gt; Sumval (son) ans = 30
So far, very good
sumVal is known to the father and grandfather, and
sumval Is counted correctly (in the first case 6 * 1, in the second case 6 * 5).
Now I delete "everything" (I think):
& gt; & Gt; Clear all & gt; & Gt; Clear work & gt; & Gt; Clear ans
and I just create one variable:
& gt; & Gt; Sons = myClass.son;
Now comes the kicker - unexpected answer
& gt; & Gt; SumVal (son) ans = 30
When I observe the loaded variable, I
& gt; & Gt;
There is no
grandfather example, and the class definition file was not touched. Even so, the value of
grandfather (which I have made, then deleted) is somehow continuous.
And when I file
myClass.m , and try to create a new variable (after
clear ), I get the message shown above is. I get clues in all of my questions:
Where Matlab hides an example of my class, so that after variable
clear , and how do I clear the workspace? Without restart), then what is the definition of class "reset"?
I do not know that this is the case, but I am using matlab 7.14.0.739 (R2012a)
You have an intermediate example
myClass.father that is not being deleted by MATLAB
delete yourself Pre>
& gt; & Gt; Clear grandpa & gt; & Gt; Delete (son.precursors {1}) & gt; & Gt; Clear son> & Gt; Explicit sections & gt; & Gt; Son = myClass.son son = son> & Gt; Edit: Alternatively, you can add a disinfectant to your class
delete the function (obj) if the obj. Delete the preceding {1}, 'myClass') (obj.precursors {1}); Instead of deleting the end
and
delete (son) , use it to destroy the
clear function. Can expand and remove all instances in your tree recursively.
No comments:
Post a Comment