How to simulate a signal with a slow (sinusoidal) drift as experimental input for an app?
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ben van Zon
el 6 de Nov. de 2023
Respondida: Mathieu NOE
el 10 de Nov. de 2023
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
el 10 de Nov. de 2023
sorry, I am not a laser expert, you may have to give more info's (publication or code ?)
Respuesta aceptada
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)
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Switches and Breakers 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!