How to assign object to an array?
6 次查看(过去 30 天)
显示 更早的评论
Let's assume I got an object called A() and an array called Array(5).class How can I assign all elements of class a new object of A().
Array(1:5).class = A()
Wont work. I don't want to use for loop;
for i=1:5
Array(i).class = A()
end
P.S: I want each element of array to assign a new A() object, not the same. A() is constructor of A also.
0 个评论
采纳的回答
Walter Roberson
2012-8-5
In order to assign new A() objects, you will need to use a loop, or will need to write that many (e.g., 5) object references.
2 个评论
Walter Roberson
2012-8-5
Yes, the methods that handle multiple assignment would assign the same object to each.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!