Extracting data from handle objects
显示 更早的评论
Hey, I have following problem.
I have multiple handle class objects which all have a propertie which can either be a scalar or a vector/matrix.
I now need a way to extract the last values of those vactors/matrices from all objects, so that they form a vector again.
So for example:
obj(1).value1=[1,2,3];
obj(1).value2=[0,0,0;0.1,0.2,0.3;0.9,0.8,0.7];
obj(2).value1=[1,2,3,4,5];
obj(2).value2=[0,0,0,0,0;0.9,0.7,0.8,0.6,0.5;0.1,0.2,0.3,0.4,0.5];
...
I now need to extract the data like
value1_vector=[3,5];
value2_vector=[0,0.3,0.7;0,0.5,0.5];
At the same time, these vectors/matrices have no fixed length and I dont know the length at the start. So it would be better to save same as a cell? Would that make the extracting of the values above easier?
Maybe a change in the size is not preferable when in future the code might be tranfered to a mexfile, where a size change while runtime is inmpossible.
Many thanks in advance
3 个评论
Catalytic
2022-11-29
Strangely, it appears that you have asked 52 questions, but accepted answers to only 1 of them. Have you truly had such poor luck in getting useful answers?
Marc Laub
2022-11-29
Rik
2022-11-29
The best strategy for storing your data depends on what you want to do next.
Do not reject a solution with a loop out of hand. Loops are fast and are easy for Matlab (or a human) to translate to C(++).
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!