Process Overview #
Task Allocation #
There are two key points:
- Tasks are divided into two parts: a main part and a secondary part.
- Tasks should be independent of each other, meaning no dependencies between them.
Code Collaboration #
Software Tools #
- VS Code Editor, along with the Live Server plugin, MATLAB plugin
- MATLAB.
Naming Conventions #
- Main function should be uniformly named
main
: The main function is the one that directly computes the final result, while others should be called auxiliary functions. - Data processing code: This refers to code that does not return any value but generates data tables. It should start with
data
, e.g., converting solar altitude angle \(\phi\) to cosine value,dataCosPhi
. - Internal data conversion code: This should start with
to
, e.g., converting coordinates from a natural coordinate system to a Cartesian coordinate systemStoXY
. - Plotting code: Code related to plotting graphs should start with
fig
. - Testing code: Should start with
test
. - For other special types of functions, they should be named based on their functionality. Functions that return boolean values should start with
is
, such as a collision detection functionisCollided
; functions that return other data should start withget
.
File Documentation Comments #
Except for the common types of files mentioned in the naming conventions (data
, test
, fig
, main
), all other files should include documentation comments.
The documentation should be concise yet clear. It generally includes a brief description of the function, the input parameters, and the output parameters.
If you’re unsure how to write documentation, you can use AI assistance.
Internal Variable Naming #
Fixed Parameters #
All fixed parameters should be placed in a config.m
file located in the root directory for centralized management. Each parameter should be followed by a comment explaining its purpose, for example:
learningRate = 0.001; % Learning rate
batchSize = 32; % Batch size
numEpochs = 100; % Number of epochs
To use this configuration file in other code files, simply include the following line:
run('config.m');
Function-Internal Parameters #
All variables used within a function should be explicitly defined at the beginning of the function and should include brief Chinese comments.
F2
in VS Code to rename them.
Code Formatting #
Code formatting is mainly handled using the official MATLAB
plugin. After you activate the plugin, press Shift+Alt+F
to format your code.
Git Version Control #
A GitHub repository needs to be created to store the entire project files. Although the Live Server plugin enables faster real-time code collaboration, it is still necessary to commit and save at key development milestones to maintain the ability to roll back code.
All Git version control operations are performed on the lead developer’s computer, while other supporting developers use the Live Server plugin for more immediate code collaboration.
- Local
commit
to save small improvements push
operations are done in major increments
Code Execution #
Thanks to the latest function of the plugin MATLAB
, we can now directly run and debug in the VS Code IDE. Though there are some limitations, it deserves a standing ovation.
Other #
AI Instruction Set #
Since generative AI’s code style might differ from the project’s standards, if you need to generate an entire file, please include the following code standard instructions at the beginning of your request:
You are a mature and standardized MATLAB programmer. While correctly implementing the user's goal, you should follow these code standards:
1. Clear and concise file documentation comments: The documentation should include a brief description of the function, input parameters, and output parameters.
2. Function-internal variable names should be concise and easy to read.
3. All variables used within a function should be explicitly defined at the beginning of the function, with brief Chinese comments added next to them.
User's instruction:
Example Project #
In order to develop a project as fast and well-defined as possible, I have created an Example Project which contains all the regulations mentioned before. You can directly change the files in the example project without mnemonic cost. 😄
Code Tips #
- Parallel Execution
MATLAB supports multi-threaded computing. You can convert a typicalfor
loop to aparfor
loop for parallel execution.
parfor
functions is subject to strict requirements. Please refer to the official documentation for more details.
Huge Table Process #
The comment output of the Mathematical Model is a Huge table in .mat
file, which is usually hard to abstract the target data.
Here I directly write a simply Python program, Data extractor, to automatically operate the huge table data. With tiny modification, you can get any data you want from the .mat
file.
Utilizing the online LaTeX table editor, we can get the capacity to quickly insert the table data into your thesis.