write a function file that creates a grid for the following

write a function file that creates a grid for the following plots cosine(x) vs e^x sine(x) vs log(x) tangent(x) vs log(X) sine(X) vs cosine (X) x goes from 0 to 3pi/8 with increment of pi/8

Solution

Matlab has \'plot\' function to facilitate function visualization and comparison. I have provided a solution for the first part. You only need to replace the appropriate functions as f(i) and g(i).

For cos(x) vs e^x, f(i)=cos(i*pi/8), g(i)=exp(i*pi/8)

For sin(x) vs log(x), f(i)=sin(i*pi/8), g(i)=log(i*pi/8)

For tan(x) vs log(x), f(i)=tan(i*pi/8), g(i)=log(i*pi/8)

For sin(x) vs cos(x), f(i)=sin(i*pi/8), g(i)=cos(i*pi/8)

The general format to compare a function f(x) with another function g(x) is demonstrated for the first part:

% Get values of both functions at discrete data points

for i=0:3

f(i) = cos(i*pi/8);

g(i) = exp(i*pi/8);

end

plot(f,g);

xlabel(\'Cosine of x\');

ylabel(\'Exponential of x\');

grid on;

 write a function file that creates a grid for the following plots cosine(x) vs e^x sine(x) vs log(x) tangent(x) vs log(X) sine(X) vs cosine (X) x goes from 0 t

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site