How to add ramping in sin function

10 Ansichten (letzte 30 Tage)
RAHUL DOGRA
RAHUL DOGRA am 22 Nov. 2021
Kommentiert: Mathieu NOE am 23 Nov. 2021
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)

Akzeptierte Antwort

Mathieu NOE
Mathieu NOE am 22 Nov. 2021
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 Kommentare
RAHUL DOGRA
RAHUL DOGRA am 23 Nov. 2021
thanks alot sir. it will really help me.
Mathieu NOE
Mathieu NOE am 23 Nov. 2021
My pleasure !
would you mind accepting my answer ?
tx

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by