|
| 1 | +# Animator Documentation |
| 2 | + |
| 3 | +*Last updated: December 19, 2024* |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +Animator is a specialized MATLAB® toolbox designed to create GIF animations from MATLAB code. It provides a powerful yet simple way to visualize parameter changes in your MATLAB plots by automatically generating animated GIF files. |
| 8 | + |
| 9 | +## Key Features |
| 10 | + |
| 11 | +- Parameter sweep automation |
| 12 | +- Smooth transition generation |
| 13 | +- GIF file creation |
| 14 | +- Support for reverse animations |
| 15 | +- Customizable frame rates |
| 16 | +- Integration with MATLAB editor |
| 17 | + |
| 18 | +## Requirements |
| 19 | + |
| 20 | +- MATLAB R2022a or newer |
| 21 | +- MATLAB Editor (for code manipulation) |
| 22 | +- Write permissions in the working directory (for saving GIF files) |
| 23 | + |
| 24 | +## Core Functions |
| 25 | + |
| 26 | +### sweep.m |
| 27 | + |
| 28 | +The main function that handles the animation creation process. |
| 29 | + |
| 30 | +**Syntax:** |
| 31 | +```matlab |
| 32 | +sweep(filename, codeLine, sweepRangeText, lineNumber, nSteps, animationOption, reverseFlag, saveAnimFlag, gifFileName, framesPerSecond) |
| 33 | +``` |
| 34 | + |
| 35 | +**Parameters:** |
| 36 | +- `filename`: The target M-file containing the plot code |
| 37 | +- `codeLine`: The line of code containing the parameter to animate |
| 38 | +- `sweepRangeText`: Range specification for the parameter sweep |
| 39 | +- `lineNumber`: Line number in the file to modify |
| 40 | +- `nSteps`: Number of steps in the animation |
| 41 | +- `animationOption`: Animation style option |
| 42 | +- `reverseFlag`: Boolean to control bi-directional animation |
| 43 | +- `saveAnimFlag`: Boolean to control saving to file |
| 44 | +- `gifFileName`: Output GIF filename |
| 45 | +- `framesPerSecond`: Animation frame rate |
| 46 | + |
| 47 | +### splitCode.m |
| 48 | + |
| 49 | +Utility function for parsing code lines and extracting variable information. |
| 50 | + |
| 51 | +**Supported Code Formats:** |
| 52 | +- Simple assignment: `a = 1` |
| 53 | +- Complex expressions with numerical values |
| 54 | + |
| 55 | +## Usage Guide |
| 56 | + |
| 57 | +1. **Prepare Your Code** |
| 58 | + - Create an M-file with your plotting code |
| 59 | + - Identify the parameter you want to animate |
| 60 | + - Ensure the parameter is assigned a numerical value |
| 61 | + |
| 62 | +2. **Set Animation Parameters** |
| 63 | + - Choose the sweep range for your parameter |
| 64 | + - Decide on the number of animation steps |
| 65 | + - Set the desired frame rate |
| 66 | + - Choose whether to include reverse animation |
| 67 | + |
| 68 | +3. **Generate Animation** |
| 69 | + - Call the sweep function with your parameters |
| 70 | + - The tool will automatically: |
| 71 | + - Modify your code |
| 72 | + - Generate plot snapshots |
| 73 | + - Compile the GIF animation |
| 74 | + |
| 75 | +## Best Practices |
| 76 | + |
| 77 | +1. **Code Organization** |
| 78 | + - Keep plotting code in a separate section |
| 79 | + - Use clear variable names |
| 80 | + - Comment your animation parameters |
| 81 | + |
| 82 | +2. **Performance Optimization** |
| 83 | + - Choose appropriate step counts |
| 84 | + - Consider frame rate impact on file size |
| 85 | + - Use efficient plotting commands |
| 86 | + |
| 87 | +3. **File Management** |
| 88 | + - Use descriptive GIF filenames |
| 89 | + - Save animations in a dedicated directory |
| 90 | + - Keep backup copies of original code |
| 91 | + |
| 92 | +## Troubleshooting |
| 93 | + |
| 94 | +Common issues and solutions: |
| 95 | + |
| 96 | +1. **Line Doesn't Match Expected Assignment** |
| 97 | + - Ensure the target line contains a simple numerical assignment |
| 98 | + - Check for proper syntax in the assignment statement |
| 99 | + - Verify line number is correct |
| 100 | + |
| 101 | +2. **Animation Quality Issues** |
| 102 | + - Adjust number of steps for smoother transitions |
| 103 | + - Modify frame rate for better viewing |
| 104 | + - Consider using the reverse flag for smooth looping |
| 105 | + |
| 106 | +3. **File Access Problems** |
| 107 | + - Check write permissions in the target directory |
| 108 | + - Ensure file paths are correct |
| 109 | + - Verify MATLAB has access to all required files |
| 110 | + |
| 111 | +## Contributing |
| 112 | + |
| 113 | +For bug reports or feature requests, please use the [GitHub Issues page](https://github.com/gulley/Animator/issues). |
| 114 | + |
| 115 | +## License |
| 116 | + |
| 117 | +See the LICENSE file in the repository for detailed licensing information. |
| 118 | + |
| 119 | +--- |
| 120 | + |
| 121 | +For additional examples and tutorials, refer to the `toolbox/examples/` directory, particularly the `GettingStarted.mlx` file. |
0 commit comments