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

4 visualizzazioni (ultimi 30 giorni)
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!

Risposte (1)

Walter Roberson
Walter Roberson il 29 Ago 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.

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by