ph24010
Download
Skip this Video
Download Presentation
PH24010

Loading in 2 Seconds...

play fullscreen
1 / 20

PH24010 - PowerPoint PPT Presentation


  • 75 Views
  • Uploaded on

PH24010. MathCAD More Curve Fitting. Previously on PH24010. Linear Fitting slope(), intercept() line() Pre-process Y-data: y = k/x y = e kx. What when can’t pre-process ?. eg. y = a + bx + cx 2 Current through light bulb R changes with heat. linfit().

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' PH24010' - kelly-cox


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
ph24010

PH24010

MathCAD

More Curve Fitting

previously on ph24010
Previously on PH24010
  • Linear Fitting
  • slope(), intercept()
  • line()
  • Pre-process Y-data:
    • y = k/x
    • y = ekx
what when can t pre process
What when can’t pre-process ?
  • eg.
  • y = a + bx + cx2
  • Current through light bulb
  • R changes with heat
linfit
linfit()
  • Fitting routine for ‘linear’ combinations of functions.
  • eg: y = A + B ln(x) + C ex + D x3

Find A,B,C & D to give best fit to data.

  • Needs ‘vector of functions’
a vector of functions
A vector of functions
  • Define function of variable x
  • Create vector with n rows & 1 column
  • Fill placeholders with expressions involving x
lightbulb example
Lightbulb Example
  • Quadratic
  • A + B x + C x2
  • Call linfit() to get coeffients
create model from linfit results
Create model from linfit() results
  • Explicitly put Coeffs into model
  • better to use vector maths…(dot product)
peak fitting
Peak fitting
  • Applications in spectroscopy
  • Gaussian peak
  • need to find:
    • position
    • amplitude
    • background
    • width
genfit
genfit()
  • Generalised fit of any function
  • Need:
    • model function
    • partial derivatives of model wrt parameters
    • vector of initial guesses for each parameter
gaussian peak function
Gaussian Peak Function
  • Where:
    • y0 is the background level
    • m is the x value of the peak centre
    • w is the width of the peak at half amplitude
    • A is the amplitude of the peak maximum
function parameters
Function parameters
  • Re-write as P0, P1, P2 …

P0 is the background level (y0)

P1 is the amplitude of the peak maximum (A)

P2 is the x value of the peak centre (m)

P3 is the width of the peak at half amplitude (w)

form partial derivatives
Form Partial Derivatives
  • Use symbolic differentiation
create function vector for genfit
Create Function Vector for genfit()
  • Function takes 2 parameters:
    • Independent variable, x
    • Parameter Vector, P
  • Re-write P0,P1,P2 etc to use vector subscripts P0, P1, P2
vector function for gaussian fit
Vector function for Gaussian fit
  • Function to fit
  • dF/dP0
  • dF/dP1
  • dF/dP2
  • dF/dP3
guess values for parameters
Guess Values for Parameters
  • By inspection of graph

P0 is the background level (y0) = 2

P1 is the amplitude of the peak maximum (A) = 6

P2 is the x value of the peak centre (m) = -3

P3 is the width of the peak at half amplitude (w) = 2

call genfit
Call genfit()
  • Form model as before from coeffients & fit function

Use vector subscript to extract correct function from vector function