Borrar filtros
Borrar filtros

Generating time vector and sinusoids

13 visualizaciones (últimos 30 días)
Nick
Nick el 23 de Oct. de 2015
Respondida: Sahdev Patel el 10 de Sept. de 2020
I have an assignment to plot 2 sinusoids and i got stuck. My task is: Generate a time vector (tt) to cover a range of t that will exhibit approximately two cycles of the 4000 Hz sinusoids defined in the next part. If we use T to denote the period of the sinusoids, define the starting time of the vector tt to be equal to −T, and the ending time as +T. Then the two cycles will include t = 0. Finally, make sure that you have at least 25 samples per period of the sinusoidal wave. In other words, when you use the colon operator to define the time vector, make the increment small enough to generate 25 samples per period. Afterwards Generate two 4000 Hz sinusoids with arbitrary amplitude and time-shift. x1(t) = A1 cos(2π(4000)(t − tm1)) and x2(t) = A2 cos(2π(4000)(t − tm2))
A1 being 18, A2 being 1.2A1. tm1 being (37.2/11)T and tm2 being -(-41.3/27)T where T is period and t is time vector
My code is:
if true
% code
end
A1=18;
A2=1.2*18;
f = 4000; % sinusoid freq
T = 1/f; % period
fs = T/25; % time step
tt = -T:fs:T; % time vector
tm1=(37.2/11)*T;
tm2=-(41.3/27)*T;
X1=A1*cos(2*pi*(4000))*(tt-tm1);
subplot(3,1,1);
plot(tt,X1),grid on
title('Sinusoid #1')
hold on
X2=A2*cos(2*pi*(4000))*(tt-tm2);
subplot(3,1,2)
plot(tt,X2),grid on
When i run this script i do not get any sinusoids, just straight lines on the graph. What am i doing wrong? Thanks for your time

Respuesta aceptada

Torsten
Torsten el 23 de Oct. de 2015
X1=A1*cos(2*pi*(4000)*(tt-tm1));
instead of
X1=A1*cos(2*pi*(4000))*(tt-tm1);
Same for X2.
Best wishes
Torsten.

Más respuestas (2)

Shivansh Budakoti
Shivansh Budakoti el 27 de Sept. de 2019
How to make a 3rd subplot in this ?

Sahdev Patel
Sahdev Patel el 10 de Sept. de 2020
how to calculate tm3 ?

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by