Borrar filtros
Borrar filtros

Copy subarray with constant "thickness" in one dimension, but varying position

1 visualización (últimos 30 días)
I'm trying to copy a subarray from a larger one, within two points in one dimension that always have constant distance, but different position.
Imagine a volume V(x,y,z) with scalar values and a height-map HM(x,y) that maps two dimensions with scalar values describing the z-indices.
A "skin" of constant thickness t sits on top of HM.
How can the subvolume SV(x,y,z) between HM(x,y) and HM(x,y)+t be extracted in the most elegant way, such that the new range of z is between 1 and t?
In a simple approach this can be done by multiple loops and element-wise copying. (Which is not very efficient or parallelized). I am also thinking of building a volume of indices between the HM and HM+t maps to only access the right elements, such that they exactly fill the new orthogonal array. Unfortunately, I have not found a sensible way to do this.
In case this is a too simple question:
For the die hards: What if t is a map t(x,y) as well? (so that the new subvolume is only sparsely filled between the indices 1 and max(max(t(x,y))) and the rest is NaNs)

Respuestas (1)

Avinash
Avinash el 7 de Dic. de 2022
Hi Ianis,
First, you can create a matrix having different positions from where subarrays are supposed be extracted, for example
a(1,:)=[x1,y1] ; a(2,:)=[x2,y2] ;................
Use one for loop to access those positions, keeping a(i,:) as index.To extract the subarray ,for every iteration of for loop for different positions, you can go through the following link of MATLAB answer to know about extracting a subarray from an array:
Regards
Avinash

Categorías

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

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by