restricting get method to not process all the values

4 visualizzazioni (ultimi 30 giorni)
I have a get method that calulates a 2-d matrix based on data in a 3d-matrix. This calculation takes some time to perform if I have allot of data in the object.
function out = get.FWHM(obj)
for RowNo=1:obj.NRows
for ColumnNo=1:obj.NColumns
out(RowNo,ColumnNo)=fwhmFunctionGivingSingleValueOut( obj.Data(RowNo,ColumnNo,:) );
end
end
end
I've tried to restrict the rows and columns to be process, when I dont need to have all the values calculated, like this:
function out = get.FWHM(obj,RowIND,ColIND)
for RowNo=RowIND
for ColumnNo=ColIND
out(RowNo,ColumnNo)=fwhmFunctionGivingSingleValueOut( obj.Data(RowNo,ColumnNo,:) );
end
end
end
But Matlab doesnt like that. In principle I could place some property in the obj that keep strack of the rows and columns to operate on, but that does not seem like the best way to do it
What is the best way to restrict the get-method to only process some of the values?

Risposta accettata

Matt J
Matt J il 28 Apr 2021
There doesn't seem to be a good reason for this to be a get method. Just use a regular method.
function out = FWHM(obj,RowIND,ColIND)
for RowNo=RowIND
for ColumnNo=ColIND
out(RowNo,ColumnNo)=fwhmFunctionGivingSingleValueOut( obj.Data(RowNo,ColumnNo,:) );
end
end
end

Più risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by