PHPackages                             royopa/mat-lab-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. royopa/mat-lab-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

royopa/mat-lab-php
==================

Some Math operations on PHP with MatLab syntaxis.

3125PHP

Since Aug 20Pushed 9y ago3 watchersCompare

[ Source](https://github.com/royopa/mat-lab-php)[ Packagist](https://packagist.org/packages/royopa/mat-lab-php)[ RSS](/packages/royopa-mat-lab-php/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

MatLabPHP
=========

[](#matlabphp)

Some Math operations on PHP with MatLab syntaxis.

[![Build Status](https://camo.githubusercontent.com/4572a4696e2d779dcb95fe8b6e633ff8106220481a65529620873adc498fd88f/68747470733a2f2f7472617669732d63692e6f72672f726f796f70612f6d61742d6c61622d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/royopa/mat-lab-php)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/77386b2e34c6d7f6d01720c46de953bab462d62dbe650a7292bfa59b292b0007/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f726f796f70612f6d61742d6c61622d7068702f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/royopa/mat-lab-php/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/3e1be3ea0efaa72b786f855a555a77c6c2b4a94fe3738479615203fe3672c95c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f726f796f70612f6d61742d6c61622d7068702f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/royopa/mat-lab-php/?branch=master)

Requiring/Loading
-----------------

[](#requiringloading)

If you're using Composer to manage dependencies, you can include the following in your composer.json file:

```
{
    "require": {
        "royopa/mat-lab-php": "dev-master"
    }
}
```

or

```
composer require royopa/mat-lab-php

```

Then, after running `composer update` or `php composer.phar update`, you can load the class using Composer's autoloading:

```
require 'vendor/autoload.php';
```

Otherwise, you can simply require the file directly:

```
require_once 'path/to/MatLabPHP/src/MatLabPHP.php';
```

And in either case, I'd suggest using an alias.

```
use MatLabPHP\MatLabPHP as M;
```

Methods
-------

[](#methods)

#### stringToVector()

[](#stringtovector)

```
$matLabPHP->stringToVector(string $str);
```

- description
    - Transform a vector in the format of \[1 2 3\] to an array(1,2,3);
- parameters
    - Number, Vector or Matrix. Ex: 1 or \[1 2 3\] or \[1 2 ; 3 4\]
- return
    - Array of Number, Vector or Matrix to operate in the class.

```
$matLabPHP = new MatLabPHP();
$matLabPHP->stringToVector("[3 1 2; 5 4 7; 6 9 7]");
    //array(
        0 => array(
            0 => '3',
            1 => '1',
            2 => '2'
        ),
        1 => array(
            0 => '5',
            1 => '4',
            2 => '7'
        ),
        2 => array(
            0 => '6',
            1 => '9',
            2 => '7'
        )
    );
```

#### eye()

[](#eye)

```
$matLabPHP->eye($cols, $rows = 'eq');
```

- description
    - Create the identity matrix;
- parameters
    - cols and rows.
- return
    - Eye matrix

#### zeros()

[](#zeros)

```
$matLabPHP->zeros($cols, $rows = 'eq');
```

- description
    - Create the a matrix of zeros;
- parameters
    - cols and rows.
- return
    - Zero matrix

#### length()

[](#length)

```
$matLabPHP->length($vector, $ret = 0);
```

- description
    - Gives back the max between cols and rows of a matrix
- parameters
    - vector or matrix
- return
    - int

#### sum()

[](#sum)

```
$matLabPHP->sum($sumA, $sumB);
```

- description
    - Sumes two matrix or vectors or numbers
- parameters
    - two vector or matrix or numbers
- return
    - result

#### mean()

[](#mean)

```
$matLabPHP->mean($array);
```

- description
    - Calculate mean (simple arithmetic average).
- parameters
    - array $values
- return
    - string Mean

#### stddev()

[](#stddev)

```
$matLabPHP->stddev(array $a, $isSample = false);
```

- description
    -----------

    [](#description)
- parameters
    ----------

    [](#parameters)
- return
    ------

    [](#return)

#### variance()

[](#variance)

```
$matLabPHP->variance($a, $isSample);
```

- description
    -----------

    [](#description-1)
- parameters
    ----------

    [](#parameters-1)
- return
    ------

    [](#return-1)

#### covariance()

[](#covariance)

```
$matLabPHP->covariance(array $x_values, array $y_values);
```

- description
    -----------

    [](#description-2)
- parameters
    ----------

    [](#parameters-2)
- return
    ------

    [](#return-2)

#### correlation()

[](#correlation)

```
$matLabPHP->correlation(array $x_values, array $y_values, $isSample = false);
```

- description
    -----------

    [](#description-3)
- parameters
    ----------

    [](#parameters-3)
- return
    ------

    [](#return-3)

\##Tests

From the project directory, tests can be ran using:

```
./vendor/bin/phpunit

```

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/9d40665a360eef88be50ddf2fad41317ab6378c4ef77a767f88050ab22bef402?d=identicon)[royopa](/maintainers/royopa)

---

Top Contributors

[![royopa](https://avatars.githubusercontent.com/u/442991?v=4)](https://github.com/royopa "royopa (28 commits)")[![pmtarantino](https://avatars.githubusercontent.com/u/2265645?v=4)](https://github.com/pmtarantino "pmtarantino (3 commits)")

### Embed Badge

![Health badge](/badges/royopa-mat-lab-php/health.svg)

```
[![Health](https://phpackages.com/badges/royopa-mat-lab-php/health.svg)](https://phpackages.com/packages/royopa-mat-lab-php)
```

###  Alternatives

[lizhichao/one-sm

国密sm3

1891.5M8](/packages/lizhichao-one-sm)[protonemedia/laravel-task-runner

Write Shell scripts like Blade Components and run them locally or on a remote server

1335.5k1](/packages/protonemedia-laravel-task-runner)[xiaodi/think-pinyin

ThinkPHP 中文转拼音扩展包

344.8k](/packages/xiaodi-think-pinyin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
