Inserting Elements in middle of 1-D, 2-D, N-D Array
Mostrar comentarios más antiguos
Dear All,
I have got an array X = [1 2 3 4 5].
Want to refine the points by averaging neighbours and insert in the middle.
X1 = [1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0].. So, 5 points have become 9 points.
Is there an easier way to do it for a general array?
I would like to make it work in N-dimension also ... for refining the points.
Any help is much appreciated.
Thank You in advance,
K Vijay Anand.
Respuesta aceptada
Más respuestas (1)
This may help
X = [
1.0 2.0 3.0
4.0 5.0 6.0
7.0 8.0 9.0]
F = griddedInterpolant(X)
[xq,yq] = ndgrid(1:0.5:3);
Vq = F(xq,yq)
results in:
X =
1 2 3
4 5 6
7 8 9
F =
griddedInterpolant with properties:
GridVectors: {[1 2 3] [1 2 3]}
Values: [3×3 double]
Method: 'linear'
ExtrapolationMethod: 'linear'
Vq =
1.0000 1.5000 2.0000 2.5000 3.0000
2.5000 3.0000 3.5000 4.0000 4.5000
4.0000 4.5000 5.0000 5.5000 6.0000
5.5000 6.0000 6.5000 7.0000 7.5000
7.0000 7.5000 8.0000 8.5000 9.0000
1 comentario
Vijay Anand
el 1 de Dic. de 2020
Categorías
Más información sobre Operators and Elementary Operations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!