MATLAB Lab: Determination of the Dissociation Constant of a Weak Acid

Bhavna Rawal, Houston Community College, Physical Sciences
Author Profile
Initial Publication Date: October 27, 2026
DOI | Cite this

Summary

This MATLAB-based chemistry lab guides students through analyzing weak-acid titration data to determine the acid dissociation constant Ka. Students enter experimental data, generate titration curves, estimate the equivalence point, identify the half-equivalence point, calculate pKa and Ka, and compare results across trials. The activity develops students' skills in acid–base chemistry, data analysis, graphing, computational chemistry, and scientific interpretation using MATLAB.

Share your modifications and improvements to this activity through the Community Contribution Tool »

Learning Goals

The goal of this activity is to help students understand weak-acid equilibria and determine the acid dissociation constant Ka using titration data and MATLAB.

Concepts and Content: Students will learn to interpret weak-acid titration curves, identify the equivalence and half-equivalence points, understand the relationship between pH and pKa, calculate Ka, and use stoichiometric relationships to standardize a NaOH solution using potassium hydrogen phthalate (KHP).

Use of MATLAB: MATLAB is used to enter and organize experimental data, generate titration curves, estimate the equivalence point from the steepest change in pH, interpolate the pH at the half-equivalence point, and calculate pKa and Ka. MATLAB helps students visualize chemical behavior, analyze data efficiently, and connect mathematical calculations with experimental observations.

Higher-Order Thinking Skills: Students develop critical thinking, quantitative reasoning, computational problem-solving, data interpretation, and scientific analysis. They evaluate titration curves, compare replicate trials, consider experimental uncertainty, and explain how measurement errors may affect the calculated equilibrium constant.

Additional Skills: Students practice scientific graphing, accurate data entry, computational tool use, interpretation of numerical results, and written scientific communication. The activity also reinforces connections between laboratory measurements, chemical theory, and computational analysis.

Context for Use

This activity is designed for undergraduate general chemistry students at two year or four year colleges and universities. It is appropriate for students studying acid–base equilibria, weak-acid titration, and equilibrium constants. The activity can be completed individually or in small groups in a chemistry laboratory or computer lab and requires approximately 60–90 minutes.

Students use MATLAB to analyze titration data, plot a titration curve, estimate the equivalence point, determine the half-equivalence point, and calculate the acid dissociation constant Ka. The activity can supplement a traditional laboratory experiment by incorporating computational data analysis and visualization.

Students should have prior knowledge of acid–base reactions, molarity, titration, pH, equivalence points, and the relationship between pKa and Ka. Previous MATLAB experience is helpful but not essential. Students should have basic computer skills, including entering data, running a script, and interpreting graphs. The provided MATLAB script allows students with limited programming experience to complete the analysis and modify the data as needed.

This activity is suitable for use after students have been introduced to weak acids and acid–base titrations. It can be adapted for different class sizes, laboratory formats, and instructional levels by using experimental data collected by students or instructor provided datasets. Instructors can extend the activity by asking students to compare replicate trials, evaluate experimental uncertainty, and interpret differences in calculated equilibrium constants. The activity connects general chemistry concepts with computational chemistry, scientific data analysis, graphing, and quantitative reasoning.

Description and Teaching Materials

Purpose
Use MATLAB to analyze weak-acid titration data, plot a titration curve, estimate the equivalence point, determine the half-equivalence volume, and calculate pKa and Ka. If you collect standardization data, use the program to calculate the NaOH molarity from KHP.
Learning outcomes
1. Calculate NaOH molarity using the 1:1 reaction between KHP and NaOH.
2. Plot and interpret pH as a function of volume of NaOH added.
3. Estimate the equivalence point using the steepest region of the titration curve.
4. Use pH = pKa at the half-equivalence point and calculate Ka = 10^(-pKa).
5. Compare replicate results using the mean and sample standard deviation.

Background
For a monoprotic weak acid, HA, titrated with strong base, the reaction is HA + OH⁻ → A⁻ + H₂O. At the half-equivalence point, half of the original HA has been converted to A⁻, so [HA] = [A⁻]. The Henderson–Hasselbalch relationship then gives pH = pKa. Once pKa is estimated, Ka = 10^(-pKa).
Materials / software
MATLAB (desktop or MATLAB Online), the accompanying .m script, and your lab notebook or report sheet. This computational activity analyzes data; it does not replace required laboratory safety procedures or the actual titration.
Procedure
1. Download and open Weak_Acid_Dissociation_MATLAB_Lab.m in MATLAB.
2. Run the script once without changes. Review the titration curve and the Command Window output.
3. Part A (if you have standardization data): enter your verified KHP masses in grams and NaOH volumes delivered in mL. Check the units and run the script again. Do not use any handwritten volume until you have verified the original burret readings.
4. Part B: inspect the included first-determination data transcribed from the supplied report sheet. Replace the vectors V_NaOH_mL and pH with your own experimental data when available. Keep the two vectors the same length and enter volumes in increasing order.
5. Part C: Describe the overall shape of the curve and identify the sharp pH rise.
6. Part D: compare the maximum-slope estimate of equivalence volume with the approximately 26.30 mL value recorded on the report sheet. The derivative estimate can depend on data spacing and noise measurement.
7. Part E: calculate the half-equivalence volume, interpolate pH at that volume, and use that pH as the pKa estimate. Calculate Ka.
8. Part F: if you have three trial results, enter the three pKa values in pKa_trials to calculate each Ka, the mean Ka, and the sample standard deviation.

Data and results
Average NaOH molarity (if calculated): __________________ M
Equivalence volume used: __________________ mL
Half-equivalence volume: __________________ mL
pH at half-equivalence: __________________
pKa: __________________
Ka: __________________
Mean Ka for replicate trials (if available): __________________
Standard deviation of Ka (if available): __________________


MATLAB Lab: Determination of the Dissociation Constant of a Weak Acid (Acrobat (PDF) 149kB Oct27 26)
MAT LAB coding (Matlab File 5kB Oct27 26)


Teaching Notes and Tips

Important notes
The uploaded PDF contains report sheets rather than the full experimental procedure. The example titration data are from the first determination shown on the report sheet; the report sheet records an equivalence volume of about 26.30 mL. Verify any handwritten standardization readings against your original notebook before using them. This MATLAB version therefore focuses on the visible report-sheet data and the analysis steps.
Submit: (1) the MATLAB script with your data, (2) a labeled titration curve, (3) calculations/results, and (4) written responses to the questions.

Assessment

Questions
1.Why is KHP used to standardize NaOH, and what mole ratio is used in the calculation?
2.What part of the titration curve signals the equivalence region? Why can the maximum-slope method be affected by data spacing?
3.Explain why pH = pKa at the half-equivalence point.
4.How would an error in the equivalence volume affect the half-equivalence volume and the estimated pKa?
5.Compare the Ka values from replicate trials. Identify at least two possible sources of variation.
6.What does the calculated Ka tell you about the acid? Do not identify the unknown acid unless you have an appropriate reference value and sufficient evidence.

References and Resources

Important notes
The uploaded PDF contains report sheets rather than the full experimental procedure. The example titration data are from the first determination shown on the report sheet; the report sheet records an equivalence volume of about 26.30 mL. Verify any handwritten standardization readings against your original notebook before using them. This MATLAB version therefore focuses on the visible report-sheet data and the analysis steps.
Submit: (1) the MATLAB script with your data, (2) a labeled titration curve, (3) calculations/results, and (4) written responses to the questions.