Consider the functions below both of which are dependent on
Solution
b)
x=(1:4)\'; %this is to plot the first graph
y1=x+5;
y2=exp(3*x)+sin(x); % y1 and y2 are calculated as per the given equations
plot(x,y1,\'r--\') % plotting a graph for y1 on x using line splitter
hold on % used to add another plot to the same graph
plot(x,y2) % plotting a graph for y2 on x on the same graph
legend(\'y1\',\'y2\') % a legend is created in the graph for discriminating the plots of y1 and y2 on x
y=(0:0.1:10)\'; % y ranges values from 0 to 10 having 1000 values
x1=y+5; % x1 is same as y1
x2=exp(3*y)+sin(y); % x2 is same as y2
plot(y,x1,\'r--\') % plotting a graph for x1 on y using line splitter
hold on % used to add another plot to the same graph
plot(y,x2) % plotting a graph for x2 on y on the same graph
legend(\'x1\',\'x2\') % a legend is created in the graph for discriminating the plots of y1 and y2 on x
c) Almost same as the previous code, but said intermediate calculation of x is added.
x=(1:4)\';
y1=x+5;
x=x/10;
y2=exp(3*x)+sin(x);
plot(x,y1,\'r--\')
hold on
plot(x,y2)
legend(\'y1\',\'y2\')
y=(0:0.1:10)\';
x1=y+5;
y=y/10;
x2=exp(3*y)+sin(y);
plot(y,x1,\'r--\')
hold on
plot(y,x2)
legend(\'x1\',\'x2\')
