Multiplying sine wave with step function

Hi again!
I'm trying to produce a sampled data vector of a sine wave with the following parameters:
  • Amplitude 0.187
  • Signal Freq. 187Hz
  • Sampling rate 1600s^-1
I am running into an error and cannot figure out what the issue is with element wise multiplication of the step function and the sine wave. Code is as follows:
nn = -3:14; % index vector
uu = double(nn >= 0);% unit step
Ts = 1.6e-3;% sample time
Fs = 1600; % sample rate
t = linspace(-3, 14, Fs); % time
w = 2*pi*187; % omega
xx = 0.187*sin(w*t);% x(t) = 0.187sin(w*t)
xxuu = xx .* uu; % multiplying step function with sine wave
stem(t, xxuu)% stem plot
I am not entirely sure if this is the best way to go about this problem either. My code includes some hints I got from this site.

 Respuesta aceptada

Ameer Hamza
Ameer Hamza el 5 de Nov. de 2020
Editada: Ameer Hamza el 5 de Nov. de 2020
I am not sure how you defined 'uu' vector. But the following code works fine
Ts = 1.6e-3;% sample time
Fs = 1600; % sample rate
t = linspace(-3, 14, Fs); % time
uu = 1*(t>=0);
w = 2*pi*187; % omega
xx = 0.187*sin(w*t);% x(t) = 0.187sin(w*t)
xxuu = xx .* uu; % multiplying step function with sine wave
stem(t, xxuu)% stem plot

3 comentarios

xRah
xRah el 5 de Nov. de 2020
I tried to generate a unit step function with 1 sample time advance using the index-vector nn, which is how the 'uu' came about.
xRah
xRah el 5 de Nov. de 2020
oh and the index vector is supposed to be -3:14
xRah
xRah el 5 de Nov. de 2020
i seem to have forgotten it -.-

Iniciar sesión para comentar.

Más respuestas (3)

Paul
Paul el 5 de Nov. de 2020
Change one line to:
xxuu = xx .* (t >= tstep); % set tstep as the time when the unit step is applied
xRah
xRah el 5 de Nov. de 2020

0 votos

Thank you all for your input and help :)

Categorías

Más información sobre Audio Processing Algorithm Design en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 5 de Nov. de 2020

Respondida:

el 5 de Nov. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by