Including interpolation row by row in a matrix using a for loop
이전 댓글 표시
I have a Raman spectral data which contains 140 rows and 1317 columns.
The wavenumbers are in the range of 102-4050 with the resolution of 3.
I want to perform an interpolation to make the data set similar to a calibration data set which the
wavenumbers are in the range of 300-3425.
I have used interp1 as follow:
X = Ramandata
Wave_no_X = linspace(102,4050,1317);
Wave_no_intrest = linspace(300,3425,1000);
Interpolated = interp1(Wave_no_X, X, Wave_no_intrest);
However this would not work because X should only be a column vector X(1,:).
Therefore I tried a loop to pass all the rows of X through interp1. But the codeis not working. Could any one help?
[n,m] = size(X)
Interpolated = []
for i = 1: n
Interpolated(i) = interp1(Wave_no_X, (X(i,:)), Wave_no_intrest);
end
채택된 답변
추가 답변 (1개)
Cris LaPierre
2021년 6월 24일
You will likely find this example helpful. Just make your X values a column vector. You should transpose your Y values so each row corresponds to X. You can transpose the result back if you prefer to have the columns represent frequency.
X = linspace(102,4050,1317)';
Xq = linspace(300,3425,1000);
Interpolated = interp1(X, Ramandata', Wave_no_intrest)';
Note that this is untested, since you did not share your data.
카테고리
도움말 센터 및 File Exchange에서 Interpolation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!