xdl-matlab 0.1.0

Extended Data Language (XDL) - Rust implementation
Documentation
  • Coverage
  • 11.69%
    9 out of 77 items documented0 out of 12 items with examples
  • Size
  • Source code size: 124.48 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.98 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 14s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • gnudatalanguage/gdl
    307 68 269
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ravituringworks
xdl-matlab-0.1.0 has been yanked.

XDL-MATLAB: MATLAB Compatibility Layer

This crate provides MATLAB/Octave compatibility for XDL, enabling:

  • Loading and executing .m files
  • Transpiling MATLAB syntax to XDL
  • Mapping MATLAB functions to XDL equivalents

Features

Syntax Transpilation

Converts MATLAB code to XDL-compatible syntax:

  • Comments: %;
  • Arrays: 1-based → 0-based indexing
  • Loops: for i = 1:10for i = 0, 9
  • Element-wise ops: .**, .//, .^^

Function Mapping (~80 functions)

MATLAB XDL Notes
zeros(n) FLTARR(n) Array creation
sin(x) SIN(x) Trig functions
mean(x) MEAN(x) Statistics
plot(x, y) PLOT, y, x Plotting
disp(x) PRINT, x I/O

See function_map.rs for complete list.

Usage

As a Library

use xdl_matlab::transpile_matlab_to_xdl;

let matlab_code = r#"
x = zeros(10, 1);
for i = 1:10
    x(i) = sin(i * 0.1);
end
"#;

let xdl_code = transpile_matlab_to_xdl(matlab_code)?;
println!("{}", xdl_code);

Load .m Files

use xdl_matlab::load_matlab_file;

let xdl_code = load_matlab_file(Path::new("script.m"))?;
// Execute with XDL interpreter

Example

Input MATLAB:

% Calculate mean
x = zeros(10, 1);
for i = 1:10
    x(i) = i * 2;
end
mean_x = mean(x);
disp('Mean value:');
disp(mean_x);

Output XDL:

; Calculate mean
x = FLTARR ( 10 , 1 )
for i = 0, 9
  x [ i ] = i * 2
endfor
mean_x = MEAN ( x )
PRINT , 'Mean value:'
PRINT , mean_x

Limitations

Current Implementation

  • Basic syntax only: Functions, loops, conditionals
  • Simple indexing: Multi-dimensional arrays need work
  • No cell arrays: {} syntax not yet supported
  • No classes/objects: OOP features not implemented

Index Adjustment

MATLAB uses 1-based indexing, XDL uses 0-based:

x(1)    % MATLAB: first element
x[0]    % XDL: first element

The transpiler automatically adjusts simple numeric indices.

Roadmap

  • Lexer for MATLAB syntax
  • Basic transpiler (assignments, loops, functions)
  • Function name mapping (~80 functions)
  • Matrix operations and slicing
  • Cell arrays and structures
  • Handle/function handles (@func syntax)
  • MEX file interface
  • Package manager integration
  • Advanced indexing (end, :, etc.)

Testing

cargo test -p xdl-matlab

Contributing

Function mappings and syntax rules are in:

  • function_map.rs - Add new MATLAB→XDL function mappings
  • transpiler.rs - Extend syntax transpilation rules
  • lexer.rs - Handle new token types

License

Same as parent XDL project.