Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using MATLAB. Create a script file that calls a user-defined function within a f

ID: 3851353 • Letter: U

Question

Using MATLAB. Create a script file that calls a user-defined function within a for/end loop to symbolically compute the derivative of ln(x) on the interval from -5 to 5, containing 100 data points. Your script file should output a plot of the derivative of ln(x) (taken from your function) vs x. Use a line with circular markers for the plot and include a grid and appropriate labels.

The user-defined function should

1. Receive a single x value as input.

2. Symbolically take the derivative of the mathematical function log(x).

3. Substitute the particular x value into the derivative.

4. Return the computed derivative back to the script file to be stored in a vector.

Explanation / Answer

function dx = d_log(x)
    dx = 1./x;
end

vec = linspace(-5,5); %generate 100 numbers

results = d_log(vec); %1st result
figure
plot (vec,results,'b--o')) %plot the graph

I hope this helps you....