Generating time vector and sinusoids
显示 更早的评论
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
采纳的回答
更多回答(2 个)
Shivansh Budakoti
2019-9-27
0 个投票
How to make a 3rd subplot in this ?
类别
在 帮助中心 和 File Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!