How to simulate a signal with a slow (sinusoidal) drift as experimental input for an app?
13 次查看(过去 30 天)
显示 更早的评论
I am currently experimenting with an app in which I want to create a function that can stabilize a drifting laser input.
However, if the function doesn't work properly it could damage the laser itself. So as to prevent this from happening, I want to generate some sort of input signal that kind of imitates a laser's frequency. But how do I generate a signal with a bit of noise and a slow drift?
The eventual goal is that that signal is used as input and that my function checks every ~5 seconds whether it is within my threshold input from a given 'stabilization value' and either lowers or increases the laser's input to prevent the drift from going too far of the preferred value.
4 个评论
Mathieu NOE
2023-11-10
sorry, I am not a laser expert, you may have to give more info's (publication or code ?)
采纳的回答
Mathieu NOE
2023-11-10
hello again
this would be my suggestion
now , we are looking at very high frequencies so I wonder what signal duration you are targeting; you may reach the memory limit very rapidely
clc
clearvars
% demo
% input that is in the range of 64455378 MHz
f_signal = 64455378*1e6; % mean freq (Hz)
% slow sinusoidal drift with a maximum amplitude of 30 MHz.
f1_amplitude = 30*1e6; % frequency amplitude
f1_mod = 1; % frequency of modulation
% add a slight noise of 10 MHz (random)
f2_amplitude = 10*1e6; % frequency amplitude
%% main code
Fs = f_signal*5; % sampling frequency
duration = 1e-12; % seconds
%%%%%%%%%%%
dt = 1/Fs;
samples = floor(duration*Fs)+1;
t = (0:dt:(samples-1)*dt);
omega = 2*pi*(f_signal+f1_amplitude.*sin(2*pi*f1_mod.*t + 2*f2_amplitude.*(rand(1,samples)-0.5)));
figure(1);
plot(t,omega)
angle_increment = omega.*dt;
angle = cumtrapz(angle_increment); % angle is the time integral of omega.
signal = sin(angle);
figure(2);
plot(t,signal)
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Waveform Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!