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
Mathieu NOE
Mathieu NOE 2023년 11월 10일
sorry, I am not a laser expert, you may have to give more info's (publication or code ?)
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