Create a script file that calls a user-defined function within a for/end loop to
ID: 2316230 • Letter: C
Question
Create a script file that calls a user-defined function within a for/end loop to symbolically compute the derivative of the natural log of x, or In(x), on the interval from -5 to 5, containing 100 data points. The output of the script file should be a line with symbols, a grid and appropriate labels. The user-defined function should Receive the particular x value in the loop. 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.Explanation / Answer
// save the below code as DerivativeOfLog.m
clc
clear all
close all
function f=DerivativeOfLog(x)
syms x
G=log10(x);
f=diff(G);
end
// run the below code after saving of above
for x=-5 : 0.1 : 5
f(x)=DerivativeOfLog(x);
end
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.