How to interpolate intermediate values?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jacky Jo
el 21 de Jun. de 2018
Comentada: Jacky Jo
el 21 de Jun. de 2018
I have an array with 110 values. let say:
M1_allvalues = [1,2,10,-1,-2,..,-10, 1, 2..........,10]
I simply want to make the array to a size of 3600 values in it, by interpolating the values in between each array element. There would be approximately 32-33 values between each element to achieve 3600 values array. For example:
Between 1 and 2 in the given array some 32 values, then the beginning would be:
newArray = [1, 1.03, 1.06, 1.09........,1.97, 2,......, 3,........, 110]
How do I do that? I was thinking of this:
for i=1:length(M1_allvalues) - 1
newArray(i,1)= M1_allvalues(i,1): (32-33 vales): M1_allvalues(i + 1,1);
end
could you me some idea?
2 comentarios
Walter Roberson
el 21 de Jun. de 2018
Is it required that the existing elements all appear in the output exactly? If equal spacing were used then some elements might only be approximated.
Respuesta aceptada
KSSV
el 21 de Jun. de 2018
Editada: KSSV
el 21 de Jun. de 2018
% M1_allvalues = [1,2,3,....,110] ;
iwant = linspace(min(M1_allvalues),max(M1_allvalues ),3600) ;
3 comentarios
KSSV
el 21 de Jun. de 2018
Let A be your data.
N = round(3600/length(A)) ;
iwant = zeros(N,length(A)-1) ;
for i = 1:length(A)-1
iwant(:,i) = linspace(A(i),A(i+1),N) ;
end
iwant = iwant(:) ;
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrices and Arrays 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!