How to add ramping in sin function

10 vues (au cours des 30 derniers jours)
RAHUL DOGRA
RAHUL DOGRA le 22 Nov 2021
Commenté : Mathieu NOE le 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)

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by