# How to create a sine wave with variable frequency - Simulink

조회 수: 39 (최근 30일)
HF . 2020년 12월 8일
댓글: Mathieu NOE . 2020년 12월 13일
Hello,
I have the following problem. I have a set of data of my vehicle and need the acceleration data in the shape of a sine wave. The sine wave is then used to include some bearing faults. I could compute for every time step the frequency based on the velocity, which then can be used in the further steps.
Does anyone has an idea in how to create a sine wave with various frequency?

댓글을 달려면 로그인하십시오.

### 채택된 답변

Mathieu NOE 2020년 12월 8일
hello
if you have the frequency at each time step, you can also calculate the angular increment at each time step : d_theta = 2*pi*freq*dt.
Then you simply need to integrate it (do a cumulative sum, modulo 2pi) to get the angle, then apply sin function.

댓글을 달려면 로그인하십시오.

### 추가 답변 (1개)

Rafael Hernandez-Walls 2020년 12월 8일
something like this: (?)
t=linspace(0,2*pi,100);
f=rand(1,100);
y=sin(f.*t);
plot(t,y)
##### 댓글 수: 1없음 표시없음 숨기기
Mathieu NOE 2020년 12월 13일
here a demo for a sinus log sweep
% log sweep demo
f1 = 50; % start freq
f2 = 200; % stop freq
Fs = 1e3; % sampling frequency
duration = 30; % s
%%%%%%%%%%%
dt = 1/Fs;
samples = floor(duration*Fs)+1;
t = (0:dt:(samples-1)*dt);
log10_freq = linspace(log10(f1),log10(f2),samples);
freq = 10.^log10_freq;
omega = 2*pi*freq;
angle_increment = omega.*dt;
angle = cumtrapz(angle_increment); % angle is the time integral of omega.
signal = sin(angle);
figure(1);
plot(t,signal)
%%%%%%%%%%%

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Switches and Breakers에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!