Borrar filtros
Borrar filtros

interpolation in Matrix to have at the end equidistance points based on X

1 visualización (últimos 30 días)
I want to interpolate a Matrix based on only X values, so I have at the end equidistance points.
For example, If the Matrix is M
M=[ 1 2 1
3 5 6
6 11 17
7 12 19
11 24 25];
I need function to interpolate M making it to
M_interp=[ 1 2 1
2 3.5 3.5
3 5 6
4 7 9.667
5 9 13.333
6 11 17
7 12 19
8 15 20.5
9 18 22
10 21 23.5
11 24 25];

Respuesta aceptada

Walter Roberson
Walter Roberson el 7 de Sept. de 2022
Editada: Walter Roberson el 7 de Sept. de 2022
format long g
M=[ 1 2 1
3 5 6
6 11 17
7 12 19
11 24 25];
M_interp = interp1(M(:,1), M, min(M(:,1)):max(M(:,1)))
M_interp = 11×3
1 2 1 2 3.5 3.5 3 5 6 4 7 9.66666666666667 5 9 13.3333333333333 6 11 17 7 12 19 8 15 20.5 9 18 22 10 21 23.5
  3 comentarios
Walter Roberson
Walter Roberson el 7 de Sept. de 2022
format long g
X = 1:11;
M=[ 1 2 1
3 5 6
6 11 17
7 12 19
11 24 25];
M_interp = interp1(M(:,1), M, X)
M_interp = 11×3
1 2 1 2 3.5 3.5 3 5 6 4 7 9.66666666666667 5 9 13.3333333333333 6 11 17 7 12 19 8 15 20.5 9 18 22 10 21 23.5

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by