difficulty to use "sin" function

7 Ansichten (letzte 30 Tage)
parham kianian
parham kianian am 13 Mai 2020
Kommentiert: Stephen23 am 13 Mai 2020
Consider following:
T = 0.02; %period (sec)
w = 2 * pi / T; %w = 314.1593, angqular frequency (rad/sec)
t = 0 : 0.01 : 20; %time vector (sec)
x = sin(w*t);
plot(t,x)
What is wrong with MATLAB? A sine plot does not look like above. When I set w = 314.1593, the above figure will be plotted. Sine function is a periodic function. But above plot is something completely different. Maximum value should be equal to 1.0 but it is about 10e-12. I cannot figure out where is the problem?
  1 Kommentar
Stephen23
Stephen23 am 13 Mai 2020
You are plotting integer multiples of pi:
>> w*t(1:8)
ans =
0.00000 3.14159 6.28319 9.42478 12.56637 15.70796 18.84956 21.99115
What is sine of any integer multiple of pi ?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Mehmed Saad
Mehmed Saad am 13 Mai 2020
Either increase you sampling rate
T = 0.02; %period (sec)
w = 2 * pi / T; %w = 314.1593, angqular frequency (rad/sec)
t = 0 : 0.001 : 20; %time vector (sec)
x = sin(w*t);
plot(t,x)
or add a phase in sin
T = 0.02; %period (sec)
w = 2 * pi / T; %w = 314.1593, angqular frequency (rad/sec)
t = 0 : 0.01 : 20; %time vector (sec)
x = sin(w*t+pi/10);
plot(t,x)

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 13 Mai 2020
Your w is approximately 100*pi and your t values are all integer multiples of 1/100 . When you multiply the two together, you get an integer multiple of 1/100 * 100*pi which will give you an integer multiple of pi. sin() of an integer multiple of pi is 0 to within round-off error. SO what you are plotting is just round-off error.

Kategorien

Mehr zu Fourier Analysis and Filtering finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by