change signal frequency by known freq step
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
LO
am 1 Feb. 2023
Kommentiert: Mathieu NOE
am 1 Feb. 2023
Hi everyone, I would like to shift the frequency of raw sinewave data (around 600 Hz and recorded at sampling freq of 20kHz) of a given frequency step (say 50 Hz). I saw already this question somewhere else but somehow I haven't found a satisfactory answer. Is there a simple (perhaps recent) MATLAB function that could do that? it seems a pretty straightforward task to me but... I haven't been lucky so far.
Thank you for any tip!
0 Kommentare
Akzeptierte Antwort
Mathieu NOE
am 1 Feb. 2023
hello
try this
I assumed you wanted the output signal also sampled at 20 kHz
% create some dummy data (as it if was a record)
Fs = 20e3;
dt = 1/Fs;
samples = 1e3;
f1 = 600;
% data you would get from a record at Fs = 20 kHz
t1 = dt*(0:samples-1);
y1 = sin(2*pi*f1*t1);
dt1 = mean(diff(t1));
Fs = 1/dt1;
% freq shift for output signal
f2 = f1+50;
f_ratio = f1/f2; % freqs ratio
dt2 = dt1*f_ratio;
tmp = dt2*(0:samples-1); % time compression (at iso samples signal length)
% resample the data at 20 kHz
t2 = (tmp(1):dt1:tmp(end));
y2 = interp1(tmp,y1,t2,'linear');
plot(t1,y1,t2,y2);
2 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!