Why don't 2 signals 180 degrees out of phase add up to an array of zeros?

1 view (last 30 days)
I have this code:
amp=1;
fs=24000;
duration=2;
t=0:1/fs:duration;
freq = 1000;
Y=amp*sin(2*pi*freq*t+deg2rad(0));
Yi=amp*sin(2*pi*freq*t+deg2rad(180));
combined=Y+Yi;
plot(t(1:24),Y(1:24),'b'); hold on;
plot(t(1:24),Yi(1:24),'r'); hold on;
plot(t(1:24),combined(1:24),'g')
combined(1:24)
My question is: Why doesn't 'combined' add the two out of phase signals to an array of zeros? shouldn't 2 signals 180 degrees out of phase cancel each other out completely? Why are there still very small fluctuations about zero? Is it something about the "deg2rad" function, but they just say "meh, the difference from zero is close enough"?

Accepted Answer

Walter Roberson
Walter Roberson on 27 Jul 2016

More Answers (0)

Community Treasure Hunt

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

Start Hunting!