how to get the ceiling and floor values of data in an array?

5 次查看(过去 30 天)
i have a file that holds 100x3 values of coordinates. the 3 columns represent the xyz plain.
taking the first row of values in the pCoords file, we have:
[120.639107128470, 0.677434823554889, 76.2799587504780]
i want to make an array that has the values of both ceiling and floor of all the values in the array.
for instance, i want an array which stores the [120,121], [0,1], and [76,77] and rest of the values.
can anyone help me?
thanks!

回答(1 个)

Walter Roberson
Walter Roberson 2021-8-29
output = permute(cat(3, floor(pCoords), ceil(pCoords)), [1 3 2])
the result will be 100 x 2 x 3 -- so for any given location pCoords(J,K), output(J,:,K) will be the row of two values corresponding to the floor and ceiling. This output arrangement was chosen because you show the output in the form of a row for each value.

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

标签

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by