Is it possible to write methods that iteratively process each element of an objectarray without writing for-loops each time?
이전 댓글 표시
If I have such an objectarray:
classdef ObjectArray
properties
Value
end
methods
function obj = ObjectArray(F)
if nargin ~= 0
m = size(F,1);
n = size(F,2);
obj(m,n) = obj;
for i = 1:m
for j = 1:n
obj(i,j).Value = F;
end
end
end
end
end
end
An instance A is created as:
F = magic(5);
A = ObjectArray(F);
And I would like to calculate the mean, the max, or do whatever calculations based on each obj.Value, then is it possible to write methods without iterations in each of them?
I expect something like this:
function obj = get.mean(obj)
obj.mean = mean(obj.value)
end
but apparently it doesn't work.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Use System Objects에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!