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

6 次查看(过去 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 个评论
Ben van Zon
Ben van Zon 2023-11-10
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?

请先登录,再进行评论。

采纳的回答

Mathieu NOE
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 个)

类别

Help CenterFile Exchange 中查找有关 Switches and Breakers 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by