Ph24010
Download
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