In: Computer Science
matlab
What does the following:
Draw two figures (or two pictures) side by side using the rules of
drawing (names for axes, title for drawing etc ...) both in the
same frame
The first figure shows the exponential function (solid red line)
and the natural logarithmic function (black dashed line) on the
space [0,10].
The second figure shows the sine (black dotted line) and the cosine
function (connected in blue and on it) on the space [0.15].
First of all, it's clear that we have to use subplots having 1 row and 2 columns. Then in each frame, we have to plot 2 graphs as stated in question having said color and linestyle.
For all of this, we are going to use the subplot function and others to get what we want.
clear;
clc;
a = 1:0.001:10;
a_exp = e.^a;
a_log = log(a);
subplot(1,2,1);
plot(a,a_exp,'r');
hold on;
plot(a,a_log,'k--');
hold off;
grid on;
title("Exponentianl and log graph");
xlabel("values");
ylabel("Tranformed values");
legend('exponential','natural log');
a = 1:0.001:15;
a_sin = sin(a);
a_cos = cos(a);
subplot(1,2,2);
plot(a,a_sin,'k:');
hold on;
plot(a,a_cos,'b');
hold off;
grid on;
title("Sin and Cos graph");
xlabel("values");
ylabel("Tranformed values");
legend('sin','cos');