📊

Module 8 Video - Polyfit: Exponential Trendlines

Mar 7, 2025

Lecture Notes: Generating Exponential Trend Lines in MATLAB

Overview

  • Focus on modeling the decay of brightness in a phosphorescent strontium aluminate compound using an exponential model.
  • Data set includes:
    • t: Time points (hours) for brightness measurement.
    • LR: Relative brightness (current brightness / initial brightness).
    • At time zero: Relative brightness = 1.

Plotting the Data

  • Initial Plot: Bare bones graph
    • No grid lines, labels, or rules.
  • Axis Font Size Adjustment
    • Use AH.fontsize = 18 to resize font and adjust grid line spacing.

Adding Labels and Titles

  • X Label: Time (hours)
    • Older method: Specifying font size within xlabel() function.
  • Y Label (Relative Brightness)
    • New method: Assign a text object to a variable (e.g., yl = ylabel()), then use yl.fontsize = 16.
  • Title
    • Assign text object to a variable (e.g., t = title()), then adjust properties.
    • Note: Title is bold by default, can be multiple lines using cell array.

Strontium Aluminate Compounds

  • Generic term for compounds with strontium, aluminum, and oxygen.
  • Different compounds based on element ratios.
  • Fluorescence achieved by adding a dopant (e.g., europium or dysprosium).

Calculating Model Parameters

  • Use polyfit() with log() of LR to fit data:
    • M: Extracted from first element.
    • B: Calculated as e raised to the second element.
  • Create theoretical data set:
    • Use linspace() to generate equally spaced time values.
    • Ensure first and last elements match data points.

Plotting the Model

  • Use hold on to plot the theoretical data on the same graph.
  • Check trend line fit visually for accuracy.

Adding Trendline Equation

  • Use sprintf() to format equation:
    • Insert B and M values with proper formatting for subscripts and superscripts.
    • Employ curly braces for superscripting.
  • Place equation on the graph with the text() function:
    • Create a text object for further customization.
  • Customization Options:
    • Adjust font size, color, background, and edge color using dot notation.

Conclusion

  • Demonstrated the application of exponential models in MATLAB.
  • Highlighted methods for customization and refinement of data visualization.
  • Next steps: Transition to a new topic.