Is {} used as index array in class?
显示 更早的评论
Hi, While I am studying Matlab object oriented I found this example and I want to confirm it.
I have a constructor:
function obj = DocPortfolio(name,varargin)
if nargin > 0
obj.name = name;
for k = 1:length(varargin)
obj.indAssets{k} = varargin(k);
assetValue = obj.indAssets{k}{1}.currentValue;
obj.totalValue = obj.totalValue + assetValue;
end
end
end
indAssets is an array property. Is it true that obj.indAssets{k} is a way to index into this array? Cause I have never use {} to index array before. And what is obj.indAssets{k}{1} in next line?
This is the link to the example: http://www.mathworks.com/help/matlab/matlab_oop/a-simple-class-hierarchy.html
Thanks!
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Functions 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!