How to interpolate intermediate values?
2 views (last 30 days)
Show older comments
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 Comments
Walter Roberson
on 21 Jun 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.
Accepted Answer
KSSV
on 21 Jun 2018
Edited: KSSV
on 21 Jun 2018
% M1_allvalues = [1,2,3,....,110] ;
iwant = linspace(min(M1_allvalues),max(M1_allvalues ),3600) ;
3 Comments
KSSV
on 21 Jun 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(:) ;
More Answers (0)
See Also
Categories
Find more on Matrices and Arrays 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!