%% SL 12
%% script evaluates two hyperbolic 
%  functions and plot them
x  = linspace(-1, 1, 51);
f1 = sinh(x);
f2 = cosh(x);
figure;
plot(x, f1, 'bs-');
hold on;
plot(x, f2, 'rd--');
ylim([-1.5 1.5]);
legend('f_1(x)=sinh(x)', 'f_2(x)=cosh(x) ', ...
'Location', 'best');
xlabel('x'); 
ylabel('f_1(x), f_2(x)');
grid on;

%% SL 16
close all; clear; clc;
x = -3/2*pi:pi/100:3/2*pi;
y = tan(x);
z = y.*(abs(y) < 1e10);
figure;
plot(x, y);
hold on;
plot(x, z, '--r', 'LineWidth', 2);
axis([-3/2*pi, 3/2*pi, -40, 40]);
legend('Original', 'Limited values');
xlabel('x (rad)');
ylabel('tan(x) (-)');

%% SL 23
x  = 0:0.1:10;
y1 = 200 * exp(-0.05*x) .* sin(x);
y2 = 0.8 * exp(x);

hAx = subplot(1, 2, 1);
yyaxis left;
lin1Obj = plot(x, y1);
yyaxis right;
lin2Obj = plot(x, y2);
 
lin1Obj.Color = 'k';
lin2Obj.Color = 'b';
 
hAx.YAxis(1).Color  = 'k';
hAx.YAxis(2).Color  = 'b';
 
subplot(1, 2, 2);
plot(x, y1, x, y2);

%% SL 25
x  = 0:2:50;
y1 = exp(0.05*x).*sin(x);
y2 = exp(0.01*x).*cos(x);

figure('Color', 'w');
subplot(2, 2, 1);
stem(x, y1, 'MarkerFaceColor', 'blue'); hold on;
stem(x, y2, 'MarkerFaceColor', 'red', 'Marker', 'square'); grid on;
legend('e^{x/20}sin(x)', 'e^{x/100}cos(x)', 'Location', 'Northwest');
xlabel('x'); ylabel('y1, y2'); title('Display using STEM');
 
subplot(2, 2, 2);
plot(x, y1, 'bo-', x, y2, 'g*--');
legend('f_1 (x)', 'f_2 (x)', 'Location', 'Southwest');
xlabel('0:2:50'); ylabel('y_1 = f_1(x), y_2 = f_2(x)');
title('Display using PLOT');
 
subplot(2, 2, [3, 4]);
stairs(x, y1, 'LineWidth', 2); hold on; grid on;
stairs(x, y2, 'Color', 'r', 'Marker', 'x', 'LineWidth', 2);
title('Display using STAIRS');

%% SL 34
CH = repmat(eye(2), 4, 4);

figure;
imagesc(CH);
colormap gray;

%% SL 40
myLineObj = plot(0:10);

% get function
myLineWidth = get(myLineObj, ...
   'LineWidth');
% set function
set(myLineObj, ...
   'Color', 'g', ...
   'LineStyle', ':', ...
   'LineWidth', myLineWidth + 1.5);

%% SL 41
myLineObj = plot(sin(0:0.2:2*pi));

myLineObj.Color	= 'r';
myLineObj.LineStyle	= 'none';
myLineObj.Marker	= '^';