How to interpolate intermediate values?
조회 수: 2 (최근 30일)
이전 댓글 표시
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
Walter Roberson
2018년 6월 21일
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.
채택된 답변
KSSV
2018년 6월 21일
편집: KSSV
2018년 6월 21일
% M1_allvalues = [1,2,3,....,110] ;
iwant = linspace(min(M1_allvalues),max(M1_allvalues ),3600) ;
댓글 수: 3
KSSV
2018년 6월 21일
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(:) ;
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!