restricting get method to not process all the values

1 visualización (últimos 30 días)
Micke Malmström
Micke Malmström el 28 de Abr. de 2021
Comentada: Micke Malmström el 28 de Abr. de 2021
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?

Respuesta aceptada

Matt J
Matt J el 28 de Abr. de 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

Más respuestas (0)

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by