# Chapter 10 MATLAB-to-Python conversions

This folder contains literal Python conversions of the uploaded MATLAB files. Variable names, calculations, line colors, line widths, markers, axis limits, comments, and figure organization were retained as closely as practical.

## Requested plotting changes

- Every explicit MATLAB font size was reduced by 2 points. For example, `FontSize`, 16 became `fontsize=14`.
- MATLAB pixel figure sizes are converted to Matplotlib inches at 100 dpi and capped to fit comfortably in a normal plot window.
- The supplied `subaxis.m` and `parseArgs.m` utilities were converted to `subaxis.py` and `parse_args.py`.
- Small compatible `arrowhead.py` and `arrow3.py` helpers are included because the corresponding MATLAB helper files were referenced but were not uploaded.

## Files

- `fig10_1.py`
- `fig10_3.py`
- `fig10_4.py`
- `fig10_5.py`
- `fig10_6.py`
- `fig10_7.py`
- `fig10_8.py` (also produces the figure identified as fig10_9 in the MATLAB comments)
- `fig10_10.py`
- `fig10_11.py`
- `fig10_12.py`
- `fig10_13.py`
- `fig10_14.py`
- `parse_args.py`
- `subaxis.py`
- `arrowhead.py`
- `arrow3.py`
- `plot_helpers.py`

## Installation

From Terminal, change to this folder and run:

```bash
python3 -m pip install -r requirements.txt
```

## Running a figure

For example:

```bash
python3 fig10_1.py
```

Run the other figure files in the same way.

## Missing data file

`fig10_5.py` and `fig10_6.py` require the original numeric data file:

```text
crime_data_2009.txt
```

That file was referenced by the MATLAB code but was not included with this upload. Place it in this same folder before running either script. Both scripts issue a clear `FileNotFoundError` when it is absent.

## Notes on literal conversion

- MATLAB indexing was converted from 1-based to 0-based indexing where necessary.
- MATLAB `svd` output was translated using `numpy.linalg.svd`; `V` is formed as the transpose of NumPy's returned `Vh`.
- MATLAB backslash solves in `fig10_6.m` were converted to `numpy.linalg.solve`.
- Random-data plots remain random, as in the originals. Run-to-run plots can therefore differ.
- Original commented export commands were retained as commented `savefig` examples.
