MATLAB Answers

draw 30 cycles of sinusoid oscillating at 10^6 hz

30 views (last 30 days)
Hessa Alhajri
Hessa Alhajri on 23 Apr 2021 at 14:14
Commented: VBBV on 26 Apr 2021 at 7:50
i was trying to plot 30 cycles of a sinusoid oscillating at 10^6, so I tried with following code
>> fs=10^6;
>> T=1/fs;
>> tt=0:0.1:30*T;
>> m=cos(2*pi*fs*tt);
>> plot(tt,m)
but no graph is appear!

Accepted Answer

VBBV
VBBV on 23 Apr 2021 at 15:28
%f true
fs=10^6;
T=1/fs;
tt=0:0.1*T:30*T;
m=cos(2*pi*fs*tt);
plot(tt,m)
Try this

More Answers (2)


Dyuman Joshi
Dyuman Joshi on 23 Apr 2021 at 14:27
The reason no graph appears is because your variable tt contains only one element (0).
The value of 30*T is 3*10^-5, so you need to use a smaller step than 30*T to declare tt as an array of values.

Community Treasure Hunt

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

Start Hunting!