How to simulate a signal with a slow (sinusoidal) drift as experimental input for an app?

8 visualizaciones (últimos 30 días)
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 comentarios
Mathieu NOE
Mathieu NOE el 10 de Nov. de 2023
sorry, I am not a laser expert, you may have to give more info's (publication or code ?)
Ben van Zon
Ben van Zon el 10 de Nov. de 2023
Oh sorry. In general I would require an input that is in the range of 64455378 MHz which has a slight noise of 10 MHz and it has a slow sinusoidal drift with a maximum amplitude of 30 MHz.
The odd number is because I will later change it to another unit that is easier to work with, which emulates the app I intend to make.
Now the question is, how do I make this signal and use it as an input for a matlab app?

Iniciar sesión para comentar.

Respuesta aceptada

Mathieu NOE
Mathieu NOE el 10 de Nov. de 2023
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)

Más respuestas (0)

Productos


Versión

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by