Lab 2 – przykładowe rozwiązania M. Głowacki, L-10, PK
1
Laboratorium komputerowe 2 – przykładowe rozwiązania
zad. 4.
clear clc
a = -7;
b = 9;
n = 1000;
s = abs(b-a)/n;
x = a:s:b;
y1 = sin(x);
y2 = cos(x);
y3 = tan(x);
subplot(2,2,1);
plot(x, y1, 'r', 'LineWidth', 2);
t1 = title('sinus');
xl1 = xlabel('x');
yl1 = ylabel('y');
set([t1,xl1,yl1], 'FontName', 'Times New Roman',
'FontSize', 15, 'FontWeight', 'bold', 'Color', 'r');
legend('y=sin(x)');
grid on;
axis([a, b, -1.1, 1.1]);
subplot(2,2,2);
plot(x, y2, 'g', 'LineWidth', 2);
t2 = title('cosinus');
xl2 = xlabel('x');
yl2 = ylabel('y');
set([t2,xl2,yl2], 'FontName', 'Times New Roman', 'FontSize', 15, 'FontWeight', 'bold', 'Color', 'g');
legend('y=cos(x)');
grid on;
axis([a, b, -1.1, 1.1]);
Lab 2 – przykładowe rozwiązania M. Głowacki, L-10, PK
2 subplot(2,2,3:4);
plot(x, y3, 'b', 'LineWidth', 2);
t3 = title('tangens');
xl3 = xlabel('x');
yl3 = ylabel('y');
set([t3,xl3,yl3], 'FontName', 'Times New Roman', 'FontSize', 15, 'FontWeight', 'bold', 'Color', 'b');
legend('y=tg(x)');
grid on;
axis([a, b, -8, 8]);