How to interpolate intermediate values?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Walter Roberson
am 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.
Akzeptierte Antwort
KSSV
am 21 Jun. 2018
Bearbeitet: KSSV
am 21 Jun. 2018
% M1_allvalues = [1,2,3,....,110] ;
iwant = linspace(min(M1_allvalues),max(M1_allvalues ),3600) ;
3 Kommentare
KSSV
am 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(:) ;
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!