MATLAB / Python / SimLab Cheat Sheet
247 functions compared side-by-side across MATLAB, NumPy/SciPy, and SimLab. Click Run to try any example directly in SimLab.
314 results
| Task | Category | SimLab | MATLAB | Python | Notes | Actions |
|---|---|---|---|---|---|---|
Core Math84 entries | ||||||
| Absolute value | abs(x) | abs(x) | np.abs(x) import numpy as np | — | ||
| Square root | sqrt(x) | sqrt(x) | np.sqrt(x) import numpy as np | — | ||
| Cube root | cbrt(x) | x.^(1/3) | np.cbrt(x) import numpy as np | — | ||
| Power (x^y) | pow(x, y) | x.^y | np.power(x, y) import numpy as np | — | ||
| Sine (radians) | sin(x) | sin(x) | np.sin(x) import numpy as np | — | ||
| Cosine (radians) | cos(x) | cos(x) | np.cos(x) import numpy as np | — | ||
| Tangent (radians) | tan(x) | tan(x) | np.tan(x) import numpy as np | — | ||
| Inverse sine (arcsin) | asin(x) | asin(x) | np.arcsin(x) import numpy as np | — | ||
| Inverse cosine (arccos) | acos(x) | acos(x) | np.arccos(x) import numpy as np | — | ||
| Inverse tangent (arctan) | atan(x) | atan(x) | np.arctan(x) import numpy as np | — | ||
| Two-argument arctangent | atan2(y, x) | atan2(y, x) | np.arctan2(y, x) import numpy as np | — | ||
| Hyperbolic sine | sinh(x) | sinh(x) | np.sinh(x) import numpy as np | — | ||
| Hyperbolic cosine | cosh(x) | cosh(x) | np.cosh(x) import numpy as np | — | ||
| Hyperbolic tangent | tanh(x) | tanh(x) | np.tanh(x) import numpy as np | — | ||
| Inverse hyperbolic sine | asinh(x) | asinh(x) | np.arcsinh(x) import numpy as np | — | ||
| Inverse hyperbolic cosine | acosh(x) | acosh(x) | np.arccosh(x) import numpy as np | — | ||
| Inverse hyperbolic tangent | atanh(x) | atanh(x) | np.arctanh(x) import numpy as np | — | ||
| Natural logarithm (ln) | log(x) | log(x) | np.log(x) import numpy as np | — | ||
| Base-10 logarithm | log10(x) | log10(x) | np.log10(x) import numpy as np | — | ||
| Base-2 logarithm | log2(x) | log2(x) | np.log2(x) import numpy as np | — | ||
| Exponential (e^x) | exp(x) | exp(x) | np.exp(x) import numpy as np | — | ||
| Round to nearest integer | round(x) | round(x) | np.round(x) import numpy as np | SimLab/MATLAB round(x, n) rounds to n decimal places; use np.round(x, n) in Python | ||
| Round toward positive infinity (ceiling) | ceil(x) | ceil(x) | np.ceil(x) import numpy as np | — | ||
| Round toward negative infinity (floor) | floor(x) | floor(x) | np.floor(x) import numpy as np | — | ||
| Round toward zero (truncate) | fix(x) | fix(x) | np.fix(x) import numpy as np | — | ||
| Sign of a number (-1, 0, or 1) | sign(x) | sign(x) | np.sign(x) import numpy as np | — | ||
| Modulus (non-negative remainder) | mod(x, y) | mod(x, y) | np.mod(x, y) import numpy as np | Always non-negative for positive divisor. Use rem() / % for C-style remainder. | ||
| Remainder after division (C-style) | rem(a, b) | rem(a, b) | np.remainder(a, b) import numpy as np | Same sign as dividend, unlike mod() | ||
| Maximum of array or two values | max(x) | max(x) | np.max(x) import numpy as np | — | ||
| Minimum of array or two values | min(x) | min(x) | np.min(x) import numpy as np | — | ||
| Sum of array elements | sum(x) | sum(x) | np.sum(x) import numpy as np | — | ||
| Product of array elements | prod(x) | prod(x) | np.prod(x) import numpy as np | — | ||
| Cumulative sum | cumsum(x) | cumsum(x) | np.cumsum(x) import numpy as np | — | ||
| Cumulative product | cumprod(x) | cumprod(x) | np.cumprod(x) import numpy as np | — | ||
| Factorial (n!) | factorial(n) | factorial(n) | math.factorial(n) import math | — | ||
| Greatest common divisor | gcd(a, b) | gcd(a, b) | math.gcd(a, b) import math | — | ||
| Least common multiple | lcm(a, b) | lcm(a, b) | math.lcm(a, b) import math | math.lcm available in Python 3.9+ | ||
| Linearly spaced vector | linspace(a, b, n) | linspace(a, b, n) | np.linspace(a, b, n) import numpy as np | — | ||
| Logarithmically spaced vector | logspace(a, b, n) | logspace(a, b, n) | np.logspace(a, b, n) import numpy as np | — | ||
| Uniformly distributed random numbers [0, 1) | rand(m, n) | rand(m, n) | np.random.rand(m, n) import numpy as np | — | ||
| Normally distributed random numbers | randn(m, n) | randn(m, n) | np.random.randn(m, n) import numpy as np | — | ||
| Identity matrix | eye(n) | eye(n) | np.eye(n) import numpy as np | — | ||
| Matrix of zeros | zeros(m, n) | zeros(m, n) | np.zeros((m, n)) import numpy as np | — | ||
| Matrix of ones | ones(m, n) | ones(m, n) | np.ones((m, n)) import numpy as np | — | ||
| Dimensions of a matrix | size(A) | size(A) | A.shape import numpy as np | — | ||
| Number of elements | numel(x) | numel(x) | x.size import numpy as np | — | ||
| Length of largest dimension | length(x) | length(x) | max(x.shape) import numpy as np | — | ||
| Reshape array | reshape(A, m, n) | reshape(A, m, n) | A.reshape(m, n) import numpy as np | — | ||
| Sort array in ascending order | sort(x) | sort(x) | np.sort(x) import numpy as np | — | ||
| Remove duplicate values | unique(x) | unique(x) | np.unique(x) import numpy as np | — | ||
| Find indices of nonzero elements | find(x) | find(x) | np.nonzero(x) import numpy as np | np.nonzero returns a tuple; np.flatnonzero returns a flat array | ||
| Flip array left-right | fliplr(x) | fliplr(x) | np.fliplr(x) import numpy as np | — | ||
| Flip array up-down | flipud(A) | flipud(A) | np.flipud(A) import numpy as np | — | ||
| Concatenate arrays along dimension | cat(dim, A, B) | cat(dim, A, B) | np.concatenate([A, B], axis=dim-1) import numpy as np | — | ||
| Replicate and tile array | repmat(A, m, n) | repmat(A, m, n) | np.tile(A, (m, n)) import numpy as np | — | ||
| Trapezoidal numerical integration | trapz(y, x) | trapz(x, y) | np.trapz(y, x) import numpy as np | Argument order differs: MATLAB trapz(x,y), SimLab/Python trapz(y,x) | ||
| Differences between adjacent elements | sl_diff(x) | diff(x) | np.diff(x) import numpy as np | — | ||
| Numerical gradient | gradient(F) | gradient(F) | np.gradient(F) import numpy as np | — | ||
| Discrete Laplacian | del2(F) | del2(F) | ndimage.laplace(F) from scipy import ndimage | — | ||
| Real part of complex number | real(z) | real(z) | np.real(z) import numpy as np | — | ||
| Imaginary part of complex number | imag(z) | imag(z) | np.imag(z) import numpy as np | — | ||
| Complex conjugate | conj(z) | conj(z) | np.conj(z) import numpy as np | — | ||
| Phase angle of complex number (radians) | angle(z) | angle(z) | np.angle(z) import numpy as np | — | ||
| Create complex number | complex(re, im) | complex(re, im) | re + 1j*im import numpy as np | — | ||
| Check for NaN values | isnan(x) | isnan(x) | np.isnan(x) import numpy as np | — | ||
| Check for infinite values | isinf(x) | isinf(x) | np.isinf(x) import numpy as np | — | ||
| Logical AND (element-wise) | and(a, b) | and(a, b) | np.logical_and(a, b) import numpy as np | — | ||
| Logical OR (element-wise) | or(a, b) | or(a, b) | np.logical_or(a, b) import numpy as np | — | ||
| True if any element is nonzero | any(x) | any(x) | np.any(x) import numpy as np | — | ||
| True if all elements are nonzero | all(x) | all(x) | np.all(x) import numpy as np | — | ||
| Element-wise multiplication | A .* B | A .* B | A * B import numpy as np | NumPy * is element-wise by default for ndarrays | ||
| Element-wise division | A ./ B | A ./ B | A / B import numpy as np | — | ||
| Element-wise power | A .^ B | A .^ B | A ** B import numpy as np | — | ||
| Find polynomial roots | roots(p) | roots(p) | np.roots(p) import numpy as np | — | ||
| Polynomial from roots | poly(r) | poly(r) | np.poly(r) import numpy as np | — | ||
| Polynomial derivative | polyder(p) | polyder(p) | np.polyder(p) import numpy as np | — | ||
| Polynomial integral | polyint(p) | polyint(p) | np.polyint(p) import numpy as np | — | ||
| 1-D interpolation | interp1(x, y, xq) | interp1(x, y, xq) | np.interp(xq, x, y) import numpy as np | — | ||
| Cubic spline interpolation | spline(x, y, xq) | spline(x, y, xq) | CubicSpline(x, y)(xq) from scipy.interpolate import CubicSpline | — | ||
| Partial fraction decomposition | [r,p,k] = residue(b,a) | [r,p,k] = residue(b,a) | r, p, k = residue(b, a) from scipy.signal import residue | — | ||
| Access physical constant (gravity) | constants.g | 9.80665 % no built-in | scipy.constants.g import scipy.constants | 25 NIST CODATA constants | ||
| List all physical constants | const_list() | N/A | scipy.constants.physical_constants import scipy.constants | — | ||
| Interactive slider control | slider('Force', 0, 100, 50) | N/A | ipywidgets.FloatSlider() import ipywidgets | Updates plot on drag | ||
| Dropdown select | dropdown('Material', ['Steel', 'Al']) | N/A | ipywidgets.Dropdown() import ipywidgets | — | ||
Linear Algebra24 entries | ||||||
| Matrix inverse | inv(A) | inv(A) | np.linalg.inv(A) import numpy as np | — | ||
| Matrix determinant | det(A) | det(A) | np.linalg.det(A) import numpy as np | — | ||
| Eigenvalues and eigenvectors | [V, D] = eig(A) | [V, D] = eig(A) | vals, vecs = np.linalg.eig(A) import numpy as np | SimLab returns [values, vectors] like MATLAB | ||
| Singular value decomposition | [U, S, V] = svd(A) | [U, S, V] = svd(A) | U, S, Vh = np.linalg.svd(A) import numpy as np | — | ||
| LU decomposition | lu(A) | [L, U, P] = lu(A) | P, L, U = scipy.linalg.lu(A) import scipy.linalg | — | ||
| QR decomposition | qr(A) | [Q, R] = qr(A) | Q, R = np.linalg.qr(A) import numpy as np | — | ||
| Cholesky decomposition | chol(A) | chol(A) | np.linalg.cholesky(A) import numpy as np | — | ||
| Matrix rank | rank(A) | rank(A) | np.linalg.matrix_rank(A) import numpy as np | — | ||
| Solve linear system Ax = b | solve(A, b) | A \ b | np.linalg.solve(A, b) import numpy as np | — | ||
| Moore-Penrose pseudoinverse | pinv(A) | pinv(A) | np.linalg.pinv(A) import numpy as np | — | ||
| Condition number | cond(A) | cond(A) | np.linalg.cond(A) import numpy as np | — | ||
| Null space basis | nullspace(A) | null(A) | scipy.linalg.null_space(A) import scipy.linalg | — | ||
| Orthonormal basis for column space | orth(A) | orth(A) | scipy.linalg.orth(A) import scipy.linalg | — | ||
| Reduced row echelon form | rref(A) | rref(A) | sympy.Matrix(A).rref() import sympy | SymPy returns (matrix, pivot_columns) | ||
| Matrix transpose | transpose(A) or A' | A' | A.T import numpy as np | In MATLAB/SimLab A' is conjugate transpose; use A.' for plain transpose | ||
| Conjugate transpose (Hermitian) | ctranspose(A) or A' | A' | A.conj().T import numpy as np | — | ||
| Cross product of 3D vectors | cross(a, b) | cross(a, b) | np.cross(a, b) import numpy as np | — | ||
| Dot product of vectors | dot(a, b) | dot(a, b) | np.dot(a, b) import numpy as np | — | ||
| Vector or matrix norm | norm(x) | norm(x) | np.linalg.norm(x) import numpy as np | — | ||
| Trace (sum of diagonal) | trace(A) | trace(A) | np.trace(A) import numpy as np | — | ||
| Kronecker tensor product | kron(A, B) | kron(A, B) | np.kron(A, B) import numpy as np | — | ||
| Extract diagonal or create diagonal matrix | diag(v) | diag(v) | np.diag(v) import numpy as np | — | ||
| Extract upper triangular part | triu(A) | triu(A) | np.triu(A) import numpy as np | — | ||
| Extract lower triangular part | tril(A) | tril(A) | np.tril(A) import numpy as np | — | ||
Statistics60 entries | ||||||
| Arithmetic mean | mean(x) | mean(x) | np.mean(x) import numpy as np | — | ||
| Median value | median(x) | median(x) | np.median(x) import numpy as np | — | ||
| Most frequent value (mode) | mode(x) | mode(x) | scipy.stats.mode(x).mode[0] import scipy.stats | — | ||
| Standard deviation | std(x) | std(x) | np.std(x, ddof=1) import numpy as np | MATLAB/SimLab use ddof=1 (sample std) by default; NumPy default is ddof=0 | ||
| Variance | variance(x) | var(x) | np.var(x, ddof=1) import numpy as np | MATLAB/SimLab use ddof=1 by default; NumPy default is ddof=0 | ||
| Covariance (scalar or 2-arg) | cov(x, y) | cov(x, y) | np.cov(x, y) import numpy as np | — | ||
| Pearson correlation coefficient | corrcoef(x, y) | corrcoef(x, y) | np.corrcoef(x, y) import numpy as np | — | ||
| Skewness | skewness(x) | skewness(x) | scipy.stats.skew(x) import scipy.stats | — | ||
| Kurtosis (excess) | kurtosis(x) | kurtosis(x) - 3 | scipy.stats.kurtosis(x) import scipy.stats | MATLAB kurtosis() returns non-excess (normal=3); SciPy returns excess (normal=0) | ||
| Normal probability density function | normpdf(x, mu, sigma) | normpdf(x, mu, sigma) | scipy.stats.norm.pdf(x, mu, sigma) from scipy import stats | — | ||
| Normal cumulative distribution function | normcdf(x, mu, sigma) | normcdf(x, mu, sigma) | scipy.stats.norm.cdf(x, mu, sigma) from scipy import stats | — | ||
| Inverse normal CDF (quantile) | norminv(p, mu, sigma) | norminv(p, mu, sigma) | scipy.stats.norm.ppf(p, mu, sigma) from scipy import stats | — | ||
| Student's t PDF | tpdf(x, df) | tpdf(x, df) | scipy.stats.t.pdf(x, df) from scipy import stats | — | ||
| Student's t CDF | tcdf(x, df) | tcdf(x, df) | scipy.stats.t.cdf(x, df) from scipy import stats | — | ||
| Chi-squared PDF | chi2pdf(x, df) | chi2pdf(x, df) | scipy.stats.chi2.pdf(x, df) from scipy import stats | — | ||
| Chi-squared CDF | chi2cdf(x, df) | chi2cdf(x, df) | scipy.stats.chi2.cdf(x, df) from scipy import stats | — | ||
| Inverse chi-squared CDF | chi2inv(p, df) | chi2inv(p, df) | scipy.stats.chi2.ppf(p, df) from scipy import stats | — | ||
| Inverse Student's t CDF | tinv(p, df) | tinv(p, df) | scipy.stats.t.ppf(p, df) from scipy import stats | — | ||
| Inverse F-distribution CDF | finv(p, df1, df2) | finv(p, df1, df2) | scipy.stats.f.ppf(p, df1, df2) from scipy import stats | — | ||
| F-distribution PDF | fpdf(x, df1, df2) | fpdf(x, df1, df2) | scipy.stats.f.pdf(x, df1, df2) from scipy import stats | — | ||
| F-distribution CDF | fcdf(x, df1, df2) | fcdf(x, df1, df2) | scipy.stats.f.cdf(x, df1, df2) from scipy import stats | — | ||
| Polynomial curve fit | polyfit(x, y, n) | polyfit(x, y, n) | np.polyfit(x, y, n) import numpy as np | — | ||
| Evaluate polynomial | polyval(p, x) | polyval(p, x) | np.polyval(p, x) import numpy as np | — | ||
| Moving average | movmean(x, k) | movmean(x, k) | pd.Series(x).rolling(k, center=True).mean().to_numpy() import pandas as pd | — | ||
| Standardize data (z-score) | zscore(x) | zscore(x) | scipy.stats.zscore(x) from scipy import stats | — | ||
| K-means clustering | kmeans(X, k) | kmeans(X, k) | KMeans(n_clusters=k).fit(X) from sklearn.cluster import KMeans | — | ||
| Principal component analysis | pca(X) | pca(X) | PCA(n_components=k).fit_transform(X) from sklearn.decomposition import PCA | — | ||
| Percentile of data | prctile(x, p) | prctile(x, p) | np.percentile(x, p) import numpy as np | — | ||
| Interquartile range (Q3 - Q1) | iqr(x) | iqr(x) | scipy.stats.iqr(x) from scipy import stats | — | ||
| One-sample t-test | ttest(x, mu) | ttest(x, mu) | scipy.stats.ttest_1samp(x, mu) from scipy import stats | — | ||
| Multiple linear regression | regress(y, X) | regress(y, X) | np.linalg.lstsq(X, y, rcond=None) import numpy as np | For full stats use scipy.stats.linregress or statsmodels | ||
| Bootstrap resampling | bootstrap(nboot, func, data) | bootstrp(nboot, func, data) | scipy.stats.bootstrap((data,), func, n_resamples=nboot) from scipy import stats | — | ||
| Cumulative maximum | cummax(x) | cummax(x) | np.maximum.accumulate(x) import numpy as np | — | ||
| Cumulative minimum | cummin(x) | cummin(x) | np.minimum.accumulate(x) import numpy as np | — | ||
| Exponential PDF (mean = mu) | exppdf(x, mu) | exppdf(x, mu) | scipy.stats.expon.pdf(x, scale=mu) from scipy import stats | mu = mean = 1/rate. MATLAB convention. | ||
| Exponential CDF (mean = mu) | expcdf(x, mu) | expcdf(x, mu) | scipy.stats.expon.cdf(x, scale=mu) from scipy import stats | — | ||
| Inverse Exponential CDF | expinv(p, mu) | expinv(p, mu) | scipy.stats.expon.ppf(p, scale=mu) from scipy import stats | — | ||
| Uniform PDF on [a, b] | unifpdf(x, a, b) | unifpdf(x, a, b) | scipy.stats.uniform.pdf(x, a, b-a) from scipy import stats | — | ||
| Uniform CDF on [a, b] | unifcdf(x, a, b) | unifcdf(x, a, b) | scipy.stats.uniform.cdf(x, a, b-a) from scipy import stats | — | ||
| Poisson PMF | poisspdf(k, lambda) | poisspdf(k, lambda) | scipy.stats.poisson.pmf(k, lambda) from scipy import stats | — | ||
| Poisson CDF | poisscdf(k, lambda) | poisscdf(k, lambda) | scipy.stats.poisson.cdf(k, lambda) from scipy import stats | — | ||
| Binomial PMF | binopdf(k, n, p) | binopdf(k, n, p) | scipy.stats.binom.pmf(k, n, p) from scipy import stats | — | ||
| Binomial CDF | binocdf(k, n, p) | binocdf(k, n, p) | scipy.stats.binom.cdf(k, n, p) from scipy import stats | — | ||
| Gamma PDF | gampdf(x, shape, scale) | gampdf(x, a, b) | scipy.stats.gamma.pdf(x, a, scale=b) from scipy import stats | — | ||
| Gamma CDF | gamcdf(x, shape, scale) | gamcdf(x, a, b) | scipy.stats.gamma.cdf(x, a, scale=b) from scipy import stats | — | ||
| Inverse Gamma CDF | gaminv(p, shape, scale) | gaminv(p, a, b) | scipy.stats.gamma.ppf(p, a, scale=b) from scipy import stats | — | ||
| Beta PDF | betapdf(x, alpha, beta) | betapdf(x, alpha, beta) | scipy.stats.beta.pdf(x, alpha, beta) from scipy import stats | — | ||
| Beta CDF | betacdf(x, alpha, beta) | betacdf(x, alpha, beta) | scipy.stats.beta.cdf(x, alpha, beta) from scipy import stats | — | ||
| Inverse Beta CDF | betainv(p, alpha, beta) | betainv(p, alpha, beta) | scipy.stats.beta.ppf(p, alpha, beta) from scipy import stats | — | ||
| Weibull PDF | weibpdf(x, scale, shape) | wblpdf(x, a, b) | scipy.stats.weibull_min.pdf(x, b, scale=a) from scipy import stats | scale=a, shape=b | ||
| Weibull CDF | weibcdf(x, scale, shape) | wblcdf(x, a, b) | scipy.stats.weibull_min.cdf(x, b, scale=a) from scipy import stats | — | ||
| Inverse Weibull CDF | weibinv(p, scale, shape) | wblinv(p, a, b) | scipy.stats.weibull_min.ppf(p, b, scale=a) from scipy import stats | — | ||
| Lognormal PDF | lognpdf(x, mu, sigma) | lognpdf(x, mu, sigma) | scipy.stats.lognorm.pdf(x, sigma, scale=exp(mu)) from scipy import stats | mu, sigma are parameters of the underlying normal distribution | ||
| Lognormal CDF | logncdf(x, mu, sigma) | logncdf(x, mu, sigma) | scipy.stats.lognorm.cdf(x, sigma, scale=exp(mu)) from scipy import stats | — | ||
| Inverse Lognormal CDF | logninv(p, mu, sigma) | logninv(p, mu, sigma) | scipy.stats.lognorm.ppf(p, sigma, scale=exp(mu)) from scipy import stats | — | ||
| Geometric PMF (k failures before success) | geopdf(k, p) | geopdf(k, p) | scipy.stats.geom.pmf(k+1, p) from scipy import stats | MATLAB k starts at 0 (failures); scipy geom k starts at 1 (trials) | ||
| Geometric CDF | geocdf(k, p) | geocdf(k, p) | scipy.stats.geom.cdf(k+1, p) from scipy import stats | MATLAB k starts at 0 | ||
| Rayleigh PDF | raylpdf(x, sigma) | raylpdf(x, sigma) | scipy.stats.rayleigh.pdf(x, scale=sigma) from scipy import stats | — | ||
| Rayleigh CDF | raylcdf(x, sigma) | raylcdf(x, sigma) | scipy.stats.rayleigh.cdf(x, scale=sigma) from scipy import stats | — | ||
| Inverse Rayleigh CDF | raylinv(p, sigma) | raylinv(p, sigma) | scipy.stats.rayleigh.ppf(p, scale=sigma) from scipy import stats | — | ||
Signal Processing29 entries | ||||||
| Fast Fourier Transform | fft(x) | fft(x) | np.fft.fft(x) import numpy as np | — | ||
| Inverse Fast Fourier Transform | ifft(X) | ifft(X) | np.fft.ifft(X) import numpy as np | — | ||
| Shift zero-frequency to center | fftshift(X) | fftshift(X) | np.fft.fftshift(X) import numpy as np | — | ||
| Discrete Cosine Transform (Type II) | dct(x) | dct(x) | scipy.fft.dct(x, type=2) import scipy.fft | — | ||
| Inverse Discrete Cosine Transform | idct(X) | idct(X) | scipy.fft.idct(X, type=2) import scipy.fft | — | ||
| Linear convolution of two signals | conv(a, b) | conv(a, b) | np.convolve(a, b) import numpy as np | — | ||
| Cross-correlation (or autocorrelation) | xcorr(x, y) | xcorr(x, y) | np.correlate(x, y, mode="full") import numpy as np | — | ||
| Apply IIR/FIR digital filter | filter(b, a, x) | filter(b, a, x) | scipy.signal.lfilter(b, a, x) import scipy.signal | — | ||
| Zero-phase filtering (forward+reverse) | filtfilt(b, a, x) | filtfilt(b, a, x) | scipy.signal.filtfilt(b, a, x) import scipy.signal | — | ||
| Butterworth filter design | butter(n, Wn) | [b, a] = butter(n, Wn) | b, a = scipy.signal.butter(n, Wn) import scipy.signal | — | ||
| FIR filter design (windowed sinc) | fir1(n, Wn) | fir1(n, Wn) | scipy.signal.firwin(n+1, Wn) import scipy.signal | — | ||
| Chebyshev Type I filter | cheby1(n, Rp, Wn) | [b, a] = cheby1(n, Rp, Wn) | b, a = scipy.signal.cheby1(n, Rp, Wn) import scipy.signal | — | ||
| Chebyshev Type II filter | cheby2(n, Rs, Wn) | [b, a] = cheby2(n, Rs, Wn) | b, a = scipy.signal.cheby2(n, Rs, Wn) import scipy.signal | — | ||
| Find local maxima (peaks) | findpeaks(x) | [pks, locs] = findpeaks(x) | locs, props = scipy.signal.find_peaks(x) import scipy.signal | — | ||
| Power spectral density via FFT | periodogram(x) | periodogram(x) | f, Pxx = scipy.signal.periodogram(x) import scipy.signal | — | ||
| Frequency response of digital filter | freqz(b, a) | [H, w] = freqz(b, a) | w, H = scipy.signal.freqz(b, a) import scipy.signal | — | ||
| Deconvolution and polynomial division | deconv(b, a) | [q, r] = deconv(b, a) | q, r = np.polydiv(b, a) import numpy as np | — | ||
| Signal envelope via Hilbert transform | envelope(x) | envelope(x) | np.abs(scipy.signal.hilbert(x)) import scipy.signal, numpy as np | — | ||
| Resample signal by rational factor p/q | resample(x, p, q) | resample(x, p, q) | scipy.signal.resample_poly(x, p, q) import scipy.signal | — | ||
| Downsample by integer factor | decimate(x, r) | decimate(x, r) | scipy.signal.decimate(x, r) import scipy.signal | — | ||
| Hamming window | hamming(N) | hamming(N) | np.hamming(N) import numpy as np | — | ||
| Hann (Hanning) window | hanning(N) | hanning(N) | np.hanning(N) import numpy as np | — | ||
| Blackman window | blackman(N) | blackman(N) | np.blackman(N) import numpy as np | — | ||
| Kaiser window | kaiser(N, beta) | kaiser(N, beta) | np.kaiser(N, beta) import numpy as np | — | ||
| Rectangular window | rectwin(N) | rectwin(N) | np.ones(N) import numpy as np | — | ||
| Bartlett (triangular) window | bartlett(N) | bartlett(N) | np.bartlett(N) import numpy as np | — | ||
| Triangular window (no zero endpoints) | triang(N) | triang(N) | signal.triang(N) from scipy import signal | — | ||
| Gaussian window | gausswin(N, alpha) | gausswin(N, alpha) | signal.windows.gaussian(N, std) from scipy import signal | — | ||
| Welch PSD estimate | pwelch(x) | pwelch(x) | signal.welch(x) from scipy import signal | — | ||
Control Systems27 entries | ||||||
| Create transfer function H(s) | tf(num, den) | tf(num, den) | control.tf(num, den) import control | — | ||
| Create zero-pole-gain model | zpk(z, p, k) | zpk(z, p, k) | control.zpk(z, p, k) import control | — | ||
| Create state-space model | ss(A, B, C, D) | ss(A, B, C, D) | control.ss(A, B, C, D) import control | — | ||
| Bode magnitude and phase plot data | bode(H) | bode(H) | mag, phase, omega = control.bode(H) import control | — | ||
| Unit step response | stepResponse(H) | step(H) | t, y = control.step_response(H) import control | — | ||
| Impulse response | impulseResponse(H) | impulse(H) | t, y = control.impulse_response(H) import control | — | ||
| Gain and phase margins | margin(H) | [Gm, Pm, Wcg, Wcp] = margin(H) | Gm, Pm, Wcg, Wcp = control.margin(H) import control | — | ||
| Negative feedback closed-loop | feedback(H, G) | feedback(H, G) | control.feedback(H, G) import control | — | ||
| Series connection of two systems | series(H1, H2) | series(H1, H2) | control.series(H1, H2) import control | — | ||
| Parallel connection of two systems | parallel(H1, H2) | parallel(H1, H2) | control.parallel(H1, H2) import control | — | ||
| PID controller as transfer function | pid(Kp, Ki, Kd) | pid(Kp, Ki, Kd) | control.tf([Kd, Kp, Ki], [1, 0]) import control | python-control has no built-in pid(); construct manually | ||
| Poles of a transfer function | pole(H) | pole(H) | control.poles(H) import control | — | ||
| Zeros of a transfer function | zero(H) | zero(H) | control.zeros(H) import control | — | ||
| Transfer function to state-space | tf2ss(num, den) | [A,B,C,D] = tf2ss(num, den) | sys_ss = control.tf2ss(control.tf(num, den)) import control | — | ||
| State-space to transfer function | ss2tf(A, B, C, D) | [num, den] = ss2tf(A, B, C, D) | sys_tf = control.ss2tf(control.ss(A, B, C, D)) import control | — | ||
| Continuous to discrete conversion (Tustin) | c2d(H, Ts) | c2d(H, Ts) | control.c2d(H, Ts, method='bilinear') import control | — | ||
| Discrete to continuous conversion (Tustin) | d2c(Hd, Ts) | d2c(Hd, Ts) | control.d2c(Hd, method='bilinear') import control | — | ||
| Root locus plot data | rlocus(H) | rlocus(H) | control.root_locus(H) import control | — | ||
| Nyquist frequency response plot | nyquist(H) | nyquist(H) | control.nyquist_plot(H) import control | — | ||
| DC gain (steady-state gain) | dcgain(H) | dcgain(H) | control.dcgain(H) import control | — | ||
| Linear simulation (arbitrary input) | lsim(sys, u, t) | lsim(sys, u, t) | t_out, y_out = control.forced_response(sys, T=t, U=u) import control | — | ||
| Controllability matrix | ctrb(A, B) | ctrb(A, B) | ct.ctrb(A, B) import control as ct | — | ||
| Observability matrix | obsv(A, C) | obsv(A, C) | ct.obsv(A, C) import control as ct | — | ||
| Pole placement (Ackermann) | acker(A, B, p) | acker(A, B, p) | ct.acker(A, B, p) import control as ct | — | ||
| Continuous LQR | [K, S, e] = lqr(A, B, Q, R) | [K,S,e] = lqr(A,B,Q,R) | scipy.linalg.solve_continuous_are(A, B, Q, R) from scipy import linalg | — | ||
| Steady-state Kalman filter | [Kf, P, e] = kalman(A, C, Qn, Rn) | [Kf,P,e] = kalman(sys,Qn,Rn) | scipy.linalg.solve_continuous_are(A.T, C.T, Qn, Rn) from scipy import linalg | — | ||
| Discrete LQR | [K, S, e] = dlqr(A, B, Q, R) | [K,S,e] = dlqr(A,B,Q,R) | scipy.linalg.solve_discrete_are(A, B, Q, R) from scipy import linalg | — | ||
Symbolic Math19 entries | ||||||
| Declare symbolic variable | syms x or sym('x') | syms x | x = sympy.Symbol("x") import sympy | — | ||
| Symbolic differentiation | diff('x^3', 'x') | diff(f, x) | sympy.diff(f, x) import sympy | — | ||
| Symbolic integration | integrate('x^2', 'x') | int(f, x) | sympy.integrate(f, x) import sympy | — | ||
| Taylor series expansion | taylor('sin(x)', 'x', 0, 5) | taylor(f, x, a, Order, n) | sympy.series(f, x, a, n) import sympy | — | ||
| Solve equation symbolically | symsolve('x^2 - 4', 'x') | solve(eqn, x) | sympy.solve(eqn, x) import sympy | — | ||
| Simplify symbolic expression | simplify('x^2 + 2*x + 1') | simplify(expr) | sympy.simplify(expr) import sympy | — | ||
| Expand symbolic expression | expand('(x+1)^2') | expand(expr) | sympy.expand(expr) import sympy | — | ||
| Factor symbolic polynomial | factor('x^2 - 1') | factor(expr) | sympy.factor(expr) import sympy | — | ||
| Collect terms by variable | collect('x^2 + 2*x + x + 3', 'x') | collect(expr, x) | sympy.collect(expr, x) import sympy | — | ||
| Substitute value in expression | subs('x^2 + 1', 'x', '3') | subs(expr, old, new) | expr.subs(x, val) import sympy | — | ||
| Compute limit of expression | limit('sin(x)/x', 'x', 0) | limit(f, x, a) | sympy.limit(f, x, a) import sympy | — | ||
| Variable-precision arithmetic | vpa('pi', 50) | vpa(expr, digits) | sympy.N(expr, n) import sympy | — | ||
| Convert expression to LaTeX | toLatex('x^2 + 1') | latex(expr) | sympy.latex(expr) import sympy | — | ||
| Pretty-print symbolic expression | sym_pretty('x^2+2*x+1') | pretty(expr) | sympy.pretty(expr) import sympy | — | ||
| Extract polynomial coefficients | sym_coeffs('x^2+3*x+5', 'x') | coeffs(poly, x) | sympy.Poly(expr, x).all_coeffs() import sympy | — | ||
| Get polynomial degree | sym_degree('x^3+2*x+1', 'x') | polynomialDegree(poly, x) | sympy.degree(poly, x) import sympy | — | ||
| Solve simple ODE symbolically | dsolve('x^2', 'y', 'x') | dsolve(ode) | sympy.dsolve(ode) import sympy | — | ||
| Laplace transform | laplace('exp(-a*t)', 't', 's') | laplace(f, t, s) | sympy.laplace_transform(f, t, s) import sympy | — | ||
| Inverse Laplace transform | ilaplace('1/(s+a)', 's', 't') | ilaplace(F, s, t) | sympy.inverse_laplace_transform(F, s, t) import sympy | — | ||
Optimization8 entries | ||||||
| Nelder-Mead unconstrained minimization | fminsearch(f, x0) | fminsearch(f, x0) | scipy.optimize.minimize(f, x0, method='Nelder-Mead') import scipy.optimize | — | ||
| Unconstrained gradient-based minimization | fminunc(f, x0) | fminunc(f, x0) | scipy.optimize.minimize(f, x0, method='BFGS') import scipy.optimize | — | ||
| Find root of scalar function | fzero(f, x0) | fzero(f, x0) | scipy.optimize.brentq(f, a, b) import scipy.optimize | Use brentq for bracketed root-finding; root_scalar for general use | ||
| Solve system of nonlinear equations | fsolve(f, x0) | fsolve(f, x0) | scipy.optimize.fsolve(f, x0) import scipy.optimize | — | ||
| Nonlinear least-squares curve fitting | lsqcurvefit(f, x0, xdata, ydata) | lsqcurvefit(f, x0, xdata, ydata) | scipy.optimize.curve_fit(f, xdata, ydata, p0=x0) import scipy.optimize | — | ||
| Linear programming | linprog(f, A, b) | linprog(f, A, b) | scipy.optimize.linprog(f, A_ub=A, b_ub=b) import scipy.optimize | — | ||
| Mixed-integer linear programming | intlinprog(f, intcon, A, b) | intlinprog(f, intcon, A, b) | scipy.optimize.milp(f, constraints=..., integrality=...) import scipy.optimize | scipy.optimize.milp available in SciPy >= 1.7 | ||
| Quadratic programming | quadprog(H, f, A, b) | quadprog(H, f, A, b) | qpsolvers.solve_qp(H, f, A, b, solver="osqp") import qpsolvers | Requires qpsolvers package; alternatives: cvxpy, quadprog | ||
ODE Solvers8 entries | ||||||
| Adaptive RK4/5 solver (non-stiff) | ode45(f, [t0, tf], y0) | [t, y] = ode45(f, [t0 tf], y0) | sol = scipy.integrate.solve_ivp(f, [t0, tf], y0, method='RK45') import scipy.integrate | — | ||
| Adaptive RK2/3 solver (non-stiff) | ode23(f, [t0, tf], y0) | [t, y] = ode23(f, [t0 tf], y0) | sol = scipy.integrate.solve_ivp(f, [t0, tf], y0, method='RK23') import scipy.integrate | — | ||
| Adams-Bashforth-Moulton solver | ode113(f, [t0, tf], y0) | [t, y] = ode113(f, [t0 tf], y0) | sol = scipy.integrate.solve_ivp(f, [t0, tf], y0, method='LSODA') import scipy.integrate | LSODA is the closest Python equivalent to ode113 | ||
| Stiff ODE solver (MATLAB ode15s-compatible) | ode15s(f, [t0, tf], y0) | [t, y] = ode15s(f, [t0 tf], y0) | sol = scipy.integrate.solve_ivp(f, [t0, tf], y0, method='BDF') import scipy.integrate | SimLab uses L-stable SDIRK2(3); MATLAB ode15s uses variable-order BDF | ||
| Stiff ODE solver (MATLAB ode23s-compatible) | ode23s(f, [t0, tf], y0) | [t, y] = ode23s(f, [t0 tf], y0) | sol = scipy.integrate.solve_ivp(f, [t0, tf], y0, method='Radau') import scipy.integrate | SimLab uses L-stable SDIRK2(3) (same impl as ode15s); MATLAB ode23s uses Rosenbrock | ||
| Implicit trapezoidal ODE solver | ode23t(f, [t0, tf], y0) | [t, y] = ode23t(f, [t0 tf], y0) | sol = scipy.integrate.solve_ivp(f, [t0, tf], y0, method='RK23') import scipy.integrate | No exact Python equivalent; RK23 or BDF is the closest | ||
| Set ODE solver tolerances | odeset('RelTol', 1e-8, 'AbsTol', 1e-10) | opts = odeset('RelTol', 1e-8, 'AbsTol', 1e-10) | sol = solve_ivp(f, tspan, y0, rtol=1e-8, atol=1e-10) import scipy.integrate | In Python, tolerances are passed directly to solve_ivp | ||
| Phase portrait of 2D ODE system | phase(f, xrange, yrange) | % no built-in; use quiver + ode45 manually | # use matplotlib quiver + solve_ivp manually | SimLab has a unique phase() function; no direct equivalent elsewhere | ||
Plotting36 entries | ||||||
| 2D line plot | plot(x, y) | plot(x, y) | plt.plot(x, y) import matplotlib.pyplot as plt | — | ||
| 2D scatter plot | scatter(x, y) | scatter(x, y) | plt.scatter(x, y) import matplotlib.pyplot as plt | — | ||
| Bar chart | bar(x, y) | bar(x, y) | plt.bar(x, y) import matplotlib.pyplot as plt | — | ||
| Histogram | histogram(x, nbins) | histogram(x, nbins) | plt.hist(x, bins=nbins) import matplotlib.pyplot as plt | — | ||
| Stem plot | stem(x, y) | stem(x, y) | plt.stem(x, y) import matplotlib.pyplot as plt | — | ||
| Set figure title | title('text') | title('text') | plt.title('text') import matplotlib.pyplot as plt | — | ||
| Set x-axis label | xlabel('text') | xlabel('text') | plt.xlabel('text') import matplotlib.pyplot as plt | — | ||
| Set y-axis label | ylabel('text') | ylabel('text') | plt.ylabel('text') import matplotlib.pyplot as plt | — | ||
| Add legend | legend('a', 'b') | legend('a', 'b') | plt.legend(['a', 'b']) import matplotlib.pyplot as plt | — | ||
| Toggle grid lines | grid('on') | grid on | plt.grid(True) import matplotlib.pyplot as plt | — | ||
| Overlay multiple plots (hold on) | hold('on') | hold on | # plt.plot() calls automatically overlay on the same axes | Matplotlib plots on the same axes by default; no hold() needed | ||
| Create figure window | figure(n) | figure(n) | plt.figure(n) import matplotlib.pyplot as plt | — | ||
| 3D line plot | plot3(x, y, z) | plot3(x, y, z) | ax = plt.axes(projection="3d"); ax.plot3D(x, y, z) import matplotlib.pyplot as plt | — | ||
| 3D scatter plot | scatter3(x, y, z) | scatter3(x, y, z) | ax = plt.axes(projection="3d"); ax.scatter(x, y, z) import matplotlib.pyplot as plt | — | ||
| 3D surface plot | surf(X, Y, Z) | surf(X, Y, Z) | ax = plt.axes(projection="3d"); ax.plot_surface(X, Y, Z) import matplotlib.pyplot as plt | — | ||
| 3D wireframe mesh plot | mesh(X, Y, Z) | mesh(X, Y, Z) | ax = plt.axes(projection="3d"); ax.plot_wireframe(X, Y, Z) import matplotlib.pyplot as plt | — | ||
| Create 2D grid from 1D vectors | meshgrid(x, y) | [X, Y] = meshgrid(x, y) | X, Y = np.meshgrid(x, y) import numpy as np | — | ||
| Subplot layout | subplot(m, n, p) | subplot(m, n, p) | fig, axes = plt.subplots(m, n); ax = axes[row, col] import matplotlib.pyplot as plt | — | ||
| Logarithmic x-axis plot | semilogx(x, y) | semilogx(x, y) | plt.semilogx(x, y) import matplotlib.pyplot as plt | — | ||
| Logarithmic y-axis plot | semilogy(x, y) | semilogy(x, y) | plt.semilogy(x, y) import matplotlib.pyplot as plt | — | ||
| Log-log plot | loglog(x, y) | loglog(x, y) | plt.loglog(x, y) import matplotlib.pyplot as plt | — | ||
| Polar coordinate plot | polar(theta, r) | polar(theta, r) | ax = plt.subplot(projection="polar"); ax.plot(theta, r) import matplotlib.pyplot as plt | — | ||
| 2D contour plot | contour(X, Y, Z) | contour(X, Y, Z) | plt.contour(X, Y, Z) import matplotlib.pyplot as plt | — | ||
| Heatmap of 2D matrix | heatmap(Z) | imagesc(Z) | plt.imshow(Z, aspect="auto") import matplotlib.pyplot as plt | — | ||
| Pie chart | pie(values, labels) | pie(values, labels) | plt.pie(values, labels=labels) import matplotlib.pyplot as plt | — | ||
| Error bar plot | errorbar(x, y, err) | errorbar(x, y, err) | plt.errorbar(x, y, yerr=err) import matplotlib.pyplot as plt | — | ||
| Staircase (step) plot | stairs(x, y) | stairs(x, y) | plt.step(x, y) import matplotlib.pyplot as plt | — | ||
| Filled area plot | area(x, y) | area(x, y) | plt.fill_between(x, y) import matplotlib.pyplot as plt | — | ||
| Add colorbar to plot | colorbar() | colorbar | plt.colorbar() import matplotlib.pyplot as plt | — | ||
| Set axis limits | axis([xmin, xmax, ymin, ymax]) | axis([xmin xmax ymin ymax]) | plt.axis([xmin, xmax, ymin, ymax]) import matplotlib.pyplot as plt | — | ||
| Set z-axis label (3D plots) | zlabel('text') | zlabel('text') | ax.set_zlabel('text') import matplotlib.pyplot as plt | — | ||
| Display matrix as scaled image | imagesc(Z) | imagesc(Z) | plt.imshow(Z, origin="upper") import matplotlib.pyplot as plt | — | ||
| Vector field (quiver) plot | quiver(X, Y, U, V) | quiver(X, Y, U, V) | plt.quiver(X, Y, U, V) import matplotlib.pyplot as plt | — | ||
| 3D bar chart | bar3(Z) | bar3(Z) | ax = plt.axes(projection="3d"); ax.bar3d(x, y, z, dx, dy, dz) import matplotlib.pyplot as plt | — | ||
| Streamline plot of vector field | streamline(X, Y, U, V, sX, sY) | streamline(X, Y, U, V, sX, sY) | plt.streamplot(X, Y, U, V) import matplotlib.pyplot as plt | — | ||
| Histogram with normal fit overlay | histfit(x) | histfit(x) | # plt.hist(x) + scipy.stats.norm.fit(x) manually | No single equivalent; combine plt.hist and scipy.stats.norm.fit | ||
Data I/O10 entries | ||||||
| Parse CSV text into numeric array | csvread(text) | csvread(filename) | pd.read_csv(io.StringIO(text)).to_numpy() import pandas as pd; import io | MATLAB csvread reads a file; SimLab/Python parse a string | ||
| Convert numeric array to CSV string | csvwrite(data) | csvwrite(filename, data) | pd.DataFrame(data).to_csv(index=False) import pandas as pd | — | ||
| Parse CSV with headers into table | readtable(csvText) | readtable(filename) | pd.read_csv(io.StringIO(csvText)) import pandas as pd; import io | — | ||
| Convert table to CSV string | writetable(table) | writetable(T, filename) | df.to_csv(index=False) import pandas as pd | — | ||
| Encode value to JSON string | jsonEncode(value) | jsonencode(value) | json.dumps(value) import json | — | ||
| Decode JSON string to value | jsonDecode(str) | jsondecode(str) | json.loads(str) import json | — | ||
| Read spreadsheet data (Excel-style) | xlsread(csvText) | xlsread(filename) | pd.read_excel(filename) import pandas as pd | SimLab xlsread is an alias for csvread (no binary Excel support) | ||
| Write spreadsheet data (Excel-style) | xlswrite(data) | xlswrite(filename, data) | pd.DataFrame(data).to_excel(filename, index=False) import pandas as pd | SimLab xlswrite is an alias for csvwrite (no binary Excel support) | ||
| Save variable to persistent storage | save('name', value) | save('name.mat', 'varname') | np.save("name.npy", value) import numpy as np | SimLab uses browser localStorage; MATLAB uses .mat files; Python can use np.save/load | ||
| Load variable from persistent storage | load('name') | load('name.mat') | value = np.load("name.npy", allow_obj=True) import numpy as np | SimLab loads from browser localStorage; MATLAB loads from .mat files | ||
Image Processing6 entries | ||||||
| Load image | img = imread('/cat.jpg') | img = imread('cat.jpg') | img = cv2.imread('cat.jpg') import cv2 | — | ||
| Display image | imshow(img) | imshow(img) | cv2.imshow('', img) import cv2 | — | ||
| RGB → grayscale | gray = rgb2gray(img) | gray = rgb2gray(img) | gray = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) import cv2 | — | ||
| Resize image | out = imresize(img, 0.5) | out = imresize(img, 0.5) | out = cv2.resize(img, None, fx=0.5, fy=0.5) import cv2 | — | ||
| Canny edge detection | e = edge(img, 'canny') | e = edge(img, 'canny') | e = cv2.Canny(img, 50, 150) import cv2 | — | ||
| Connected components | L = bwlabel(bw) | L = bwlabel(bw) | num, L = cv2.connectedComponents(bw) import cv2 | — | ||
GPU Acceleration3 entries | ||||||
| Upload matrix to GPU | G = gpuArray(A) | G = gpuArray(A) | G = torch.tensor(A, device="cuda") import torch | — | ||
| Download from GPU | M = gather(G) | M = gather(G) | M = G.cpu().numpy() | — | ||
| GPU matrix multiply | C = gpuArray(A) * gpuArray(B); M = gather(C) | C = gpuArray(A) * gpuArray(B); M = gather(C) | C = torch.mm(A_gpu, B_gpu) | — | ||
Try SimLab — Free MATLAB® Alternative
466 functions. Runs in your browser. No install.
Open SimLab