【发布时间】:2013-12-17 05:47:19
【问题描述】:
我尝试从类函数内部从 matlab 类属性向量中删除一个条目。正确的元素会被删除,但旧条目不会被覆盖。
这是我的课:
classdef unknownPoints
properties
points;
end
methods
function removePoint(obj, num)
points = obj.points(obj.points ~= num) [1]
end
end
end
我是这样称呼的:
up = unknownPoints();
up.points = [up.points 3];
up.points = [up.points 2];
up.points = [up.points 7];
up.removePoint(3);
up.points [2]
结果是:
points = 2 7 <-- from inside the method [1]
ans = 3 2 7 <-- and that how it looks like from outside [2]
我希望从外部读取的内容类似于第一个 => [2, 7] 结果,但似乎 'points' 属性没有被覆盖。 我做错了什么?
【问题讨论】:
-
请使用推荐将
[1]等信息添加到您的代码中。而是使用%[1]
标签: matlab oop properties