Using Matlab. Please Create the script. Create a script file that calls a user-d
ID: 3851827 • Letter: U
Question
Using Matlab. Please Create the script.
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 Receive a single x value as input. Symbolically take the derivative of the mathematical function log(x). Substitute the particular x value into the derivative. Return the computed derivative back to the script file to be stored in a vector. Submit the m files to the Unit 6 Lesson 3 HW dropbox. The files will be graded on both the coding and results the file generates. Name the files as:Explanation / Answer
function dx = d_log(x)
dx = 1/x;
end
vec = linspace(-5,5); %generate 100 numbers
results = [];
for x = vec
results = [results d_log(x)]; %1st result
end
figure
plot (vec,results,'b--o')) %plot the graph
I tried my best to keep the code as simple as possible.