Professional Documents
Culture Documents
Plotting
fzero
Locating root using fzero function Command window >>x0= initial value >> x= fzero(inline(f),x0) Example >> x0=0; >> x=fzero(inline('x^3+x-3'),x0)
x= 1.2134
Numerical Differentiation
M-file (scripts) Create the M-file in window command >> edit Write the Matlab statement for numerical differentiation using 2 point forward and 2 point backward difference in editor
Save the file (File > Save) dif1.m Run the scripts in the command window >>dif1
diff command
2 point forward >> x=[1.05 1.10]; >> y=[1.02470 1.04881]; >> d=diff(y)./diff(x)
d= 0.4822
d= 0.4940
3 point Centre difference >> x=[1 1.10]; >> y=[1.0000 1.04881]; >> d=diff(y)./diff(x)
d= 0.4881
Tutorial Lab
Page 23
Each group choose 1 function only and determine root using newton method
Page 27
Each