Resampling/Interpolate Data
    6 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
Hello,
How can i resample/interpolate the signal (Sig1). Sig1 has approx.99 Hertz and Sig2 has 500 Hertz. 
First Column is the time. Second Column is the distance.
Thank you.
0 comentarios
Respuestas (1)
  Aabha
 el 6 de Feb. de 2025
        
      Editada: Aabha
 el 7 de Feb. de 2025
  
      Hi Philipp, 
You can downsample “Sig2” to match the sampling frequency of “Sig1”. This can be done using the “resample” function in MATLAB. Here is a reference code to help you with it. 
distance = Sig2(:, 2); 
time = Sig2(:, 1); 
fs1 = 99; 
fs2 = 500; 
[p, q] = rat(fs1 / fs2); %resampling factor
distanceResampled = resample(distance, p, q); 
timeResampled = linspace(time(1), time(end), length(distanceResampled))';     
Sig2Resampled = [timeResampled, distanceResampled]; 
If you would like to interpolate the signals instead of resampling, you can use the “interp1” function in MATLAB. Here is a reference code for interpolation 
timeSig1 = Sig1(:,1)'; 
distanceSig1 = Sig1(:, 2)'; 
timeSig2 = Sig2(:,2)'; 
distanceSig2 = Sig2(:, 2)'; 
interpolSig = interp1(timeSig1, distanceSig1, timeSig2, 'linear');
This code will interpolate “Sig1” such that the new signal “interpolSig” will have the same time vector “time1”. 
You can also refer to the following documentation for more details. 
0 comentarios
Ver también
Categorías
				Más información sobre Multirate Signal Processing en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

