how to get the ceiling and floor values of data in an array?
4 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Walter Roberson
on 29 Aug 2021
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 Comments
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!