Sie verfolgen jetzt diese Einreichung
- Aktualisierungen können Sie in Ihrem Feed verfolgter Inhalte sehen.
- Je nach Ihren Kommunikationseinstellungen können Sie auch E-Mails erhalten.
# MATLAB Extension
A MATLAB extension that provides seamless integration of easy/flexible syntax into MATLAB, making programming less worrisome and more intuitive. Users don't need to worry about syntax - the extension handles it automatically.
## Overview
This project provides two approaches to syntax-free MATLAB programming:
1. **Python-based Interpreter** - A standalone MATLAB-compatible interpreter built in Python
2. **MATLAB Integration** - MATLAB functions and classes that run inside MATLAB with syntax-free features
## MATLAB Integration (Primary Focus)
The MATLAB integration allows you to use easy/flexible syntax directly within MATLAB:
- **Implicit Multiplication**: `2x` → `2*x`
- **Natural Exponent**: `e^x` → `exp(x)`
- **Natural Logarithm**: `ln(x)` → `log(x)`
- **Custom Function Names**: `integrate` → `integral`, `derivative` → `diff`, `solve_eq` → `fzero`
### Installation
#### Method 1: MATLAB Add-On Explorer (Recommended)
1. Download the extension package (EasySyntaxExtension_v1.0.0.zip)
2. Open MATLAB
3. Go to **Home** → **Add-Ons** → **Manage Add-Ons**
4. Click **Install** and select the downloaded zip file
5. Follow the installation prompts
6. Restart MATLAB
#### Method 2: Manual Installation
```matlab
% Run the setup script
cd matlab
setup
% Or manually add to path
addpath('path/to/matlab');
addpath('path/to/matlab/+easy');
savepath;
```
#### Method 3: MATLAB App
1. Download the EasySyntax.mlapp file
2. Open MATLAB
3. Double-click the .mlapp file
4. The app will be installed and available in the **Apps** tab
For detailed installation instructions, see [INSTALLATION.md](INSTALLATION.md).
### Usage
```matlab
% One-line execution
result = easyExec('2x + sin(30)');
% Class-based execution
es = EasySyntax();
es.exec('x = 5');
es.exec('y = 2x');
% Package functions
result = easy.integrate(@(x) sin(x), 0, pi);
result = easy.derivative(@(x) x.^2, x);
result = easy.solve_eq(@(x) x.^2 - 4, 1);
```
## Python-based Interpreter
A standalone MATLAB-compatible interpreter built in Python with the following features:
### Core Components
1. **Lexer** - Tokenizes input with implicit multiplication and natural syntax conversion
2. **Parser** - Parses tokens into an AST
3. **Interpreter** - Executes the AST using Python numerical libraries
4. **REPL** - Interactive read-eval-print loop
### Technology Stack
- **Language**: Python 3.8+
- **Numerical Computing**: NumPy
- **Plotting**: Matplotlib
- **Scientific Computing**: SciPy
- **Symbolic Math**: SymPy (optional)
- **File I/O**: Standard Python libraries
### Key Features
- **Syntax-Free**: Implicit multiplication, natural syntax
- **MATLAB Parity**: Arrays, matrices, plotting, control flow
- **Lightweight**: No LLVM dependency
- **Cross-Platform**: Works on Windows, Linux, macOS
- **Symbolic Math**: Optional SymPy integration for symbolic computations
- **Comprehensive**: 70+ MATLAB-compatible built-in functions
### Project Structure
```
MatlabExtension/
├── src/
│ ├── lexer.py # Tokenization with implicit multiplication
│ ├── parser.py # AST parsing
│ ├── interpreter.py # AST execution using NumPy
│ ├── repl.py # Interactive REPL
│ └── builtins.py # MATLAB-compatible functions
├── tests/
│ ├── test_lexer.py # Lexer tests
│ ├── test_parser.py # Parser tests
│ └── test_interpreter.py # Interpreter tests
├── examples/
│ ├── basic_arithmetic.me
│ ├── arrays_and_matrices.me
│ ├── control_flow.me
│ ├── plotting.me
│ └── file_io.me
├── requirements.txt # Python dependencies
└── README.md # This file
```
### MATLAB Compatibility
- Arrays and matrices
- Element-wise operations (.*, ./, .^)
- Matrix operations (*, ^)
- Plotting (plot, scatter, hist, show)
- Control flow (if, elseif, else, for, while)
- Functions (user-defined and built-in)
- File I/O (read, write, append)
- Mathematical functions (sin, cos, exp, log, etc.)
- Control flow statements (break, continue)
- Constants (pi, e, true, false)
### Syntax-Free Features
- Implicit multiplication: `2x` → `2 * x`
- Natural exponent: `e^x` → `exp(x)`
- Natural logarithm: `ln(x)` → `log(x)`
- Parentheses optional in many cases
### Symbolic Math (SymPy Integration)
When SymPy is installed, the following symbolic math functions are available:
- `sympy(x)` - Create symbolic variable
- `solve(eq, var)` - Solve equations
- `diff(expr, var)` - Differentiate expressions
- `integrate(expr, var)` - Integrate expressions
- `limit(expr, var, point)` - Compute limits
- `simplify(expr)` - Simplify expressions
- `expand(expr)` - Expand expressions
- `factor(expr)` - Factor expressions
### Built-in Functions
The interpreter includes 70+ MATLAB-compatible functions including:
- Matrix operations: zeros, ones, eye, transpose, det, inv, eig, svd, rank, trace
- Array manipulation: reshape, flipud, fliplr, rot90, diag, triu, tril
- Statistical functions: mean, std, var, median, corrcoef, cov
- Mathematical functions: sin, cos, tan, exp, log, sqrt, abs, round, floor, ceil
- Random number generation: rand, randn, randi
- Polynomial functions: polyfit, polyval, roots
- Signal processing: fft, ifft, convolve
- And many more...
## Installation
```bash
pip install -r requirements.txt
```
## Usage
### Interactive REPL
```bash
python -m src.repl
```
### Running Example Files
```python
from src.lexer import Lexer
from src.parser import Parser
from src.interpreter import Interpreter
# Read and execute a file
with open('examples/basic_arithmetic.me', 'r') as f:
code = f.read()
lexer = Lexer(code)
tokens = lexer.tokenize()
parser = Parser(tokens)
ast = parser.parse()
interpreter = Interpreter()
result = interpreter.interpret(ast)
```
### Running Tests
```bash
# Run all tests
python tests/test_lexer.py
python tests/test_parser.py
python tests/test_interpreter.py
# Or run the old basic test
python test_basic.py
```
## Examples
### Basic Arithmetic
```matlab
x = 5 + 3
y = 2x # Implicit multiplication
z = e^2 # Natural exponent
```
### Arrays and Matrices
```matlab
a = [1, 2, 3, 4, 5]
b = a .* 2 # Element-wise multiplication
m1 = [[1, 2], [3, 4]]
m2 = m1 * m1 # Matrix multiplication
```
### Control Flow
```matlab
if x > 10
result = "large"
elseif x > 5
result = "medium"
else
result = "small"
end
for i = 1:10
if i == 5
break
end
sum = sum + i
end
```
### Functions
```matlab
function factorial(n)
if n <= 1
return 1
else
return n * factorial(n - 1)
end
end
fact = factorial(5)
```
### Symbolic Math (requires SymPy)
```matlab
x = sympy("x")
expr = x^2 + 2*x + 1
result = solve(expr, x)
```
## License
This project is provided as-is for educational and research purposes.
Zitieren als
Ebenezer (2026). EasySyntax (https://de.mathworks.com/matlabcentral/fileexchange/184064-easysyntax), MATLAB Central File Exchange. Abgerufen .
Allgemeine Informationen
- Version 1.0.0 (20,5 KB)
Kompatibilität der MATLAB-Version
- Kompatibel mit allen Versionen
Plattform-Kompatibilität
- Windows
- macOS
- Linux
| Version | Veröffentlicht | Versionshinweise | Action |
|---|---|---|---|
| 1.0.0 |
