how to get the ceiling and floor values of data in an array?
4 次查看(过去 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!
0 个评论
回答(1 个)
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!