% Example 10-1: Fitting an equation to data points t = 0:0.5:5; w = [6.00 4.83 3.70 3.15 2.41 1.83 1.49 1.21 0.96 0.73 0.64]; % Try linear plot first plot(t,w,'o') pause % Test exponential with log w axis semilogy(t,w,'o') pause % Test reciprocal with 1/w plot wrecip = 1./w; plot(t, wrecip, 'o'); ylabel('1/w') pause % Try exponential fit using rewritten form p = polyfit(t, log(w), 1) m = p(1); b = exp(p(2)); tm = 0:0.1:5; wm = b*exp(m*tm); plot(t, w, 'o', tm, wm);