Pass objects into function
显示 更早的评论
classdef myClass
properties
data
end
methods
function h = myClass(data)
h.data = data ;
end
end
end
This is a class defined and I want to pass its object into a function like shown in the below:
h = myClass(0);
chg(h);
h.data
function chg(h)
h.data = h.data+2;
end
But line h.data prints 0 instead of 2. Why is that and where is the mistake in my code.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Create System Objects 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!