How to add ramping in sin function

10 ビュー (過去 30 日間)
RAHUL DOGRA
RAHUL DOGRA 2021 年 11 月 22 日
コメント済み: Mathieu NOE 2021 年 11 月 23 日
I want to add ramping in sin function for first few mili seconds as shown in figure (red wave) how can I do that. I was trying to plot direct sine function but I am not able to get any ramping. I want to create a dynamic laoding of 5 m/sec2 having a frequency of 20 Hz.
right now i am doing this:
t = 0:0.001:1;
x = 5*sin((125.66)*t);
plot(t,x)

採用された回答

Mathieu NOE
Mathieu NOE 2021 年 11 月 22 日
hello
see my little demo below :
clc
clearvars
% signal
Fs = 100;
dt= 1 /Fs;
samples = 1e3;
freq = 10;
t = (0:samples-1)*dt;
x = 3*sin(2*pi*freq*t);
%% create a window (ramp of given slope)
% ascending ramp
t0 = 1; % start time of ramp
t1 = 2; % stop time of ramp
window = zeros(1,length(t));
ind = find(t>=t0 & t<= t1);
tmp = linspace(0,1,length(ind));
window(ind) = tmp;
window(t>t1) = 1;
% descending ramp
t2 = 6; % start time of ramp
t3 = 8; % stop time of ramp
ind = find(t>=t2 & t<= t3);
tmp = linspace(1,0,length(ind));
window(ind) = tmp;
window(t>t3) = 0;
% windowed signal
xw = x.*window;
plot(t,xw)
  2 件のコメント
RAHUL DOGRA
RAHUL DOGRA 2021 年 11 月 23 日
thanks alot sir. it will really help me.
Mathieu NOE
Mathieu NOE 2021 年 11 月 23 日
My pleasure !
would you mind accepting my answer ?
tx

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by