Last active
December 13, 2015 18:19
-
-
Save StephanDollberg/4954704 to your computer and use it in GitHub Desktop.
Shows sign of from si(2x) * cos(2x) in matlab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
figure; | |
% sizes | |
y_size = 1.5; | |
x_size = 2*pi; | |
% colors | |
cos_col = 'c'; | |
si_col = 'b'; | |
sign_col = 'r'; | |
% variables and functions | |
x = -x_size:0.00001:x_size; | |
cos_y = cos(2*x); | |
sinc_y = sinc(2*x/pi); | |
signs = sign(cos_y.*sinc_y); | |
% plot graphs | |
hold on; | |
h = plot(x,cos_y); | |
h2 = plot(x,sinc_y); | |
h3 = plot(x, signs); | |
% colors and axes | |
set(h, 'Color', cos_col); | |
set(h2, 'Color', si_col); | |
set(h3, 'Color', sign_col); | |
axis([-2*pi 2*pi -1.5 1.5]); | |
grid on; | |
% vertical bars in interval of stepzie | |
stepsize = pi/4; | |
for i= -x_size:stepsize:x_size | |
line([i i], [-1 * y_size y_size], 'Color', [0.2 0.2 0.2]); | |
end | |
% some help text | |
xlabel('x'); | |
ylabel('cos(gr?n) und si(rot)'); | |
title('Phase-Sign'); | |
text(-2, 1.25, 'cos(2x)', 'Color', cos_col); | |
text(-2, 1.15, 'si(2x)', 'Color', si_col); | |
text(-2, 1.05, 'sign(cos(2x) * si(2x))', 'Color', sign_col); | |
set(gca, 'XTick', -x_size:stepsize:x_size); | |
hold off; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment