Including interpolation row by row in a matrix using a for loop
Mostra commenti meno recenti
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
Risposta accettata
Più risposte (1)
Cris LaPierre
il 24 Giu 2021
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.
Categorie
Scopri di più su Interpolation in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!