{
  "name": "Output-length rules for MATLAB conv shapes and SciPy convolve modes",
  "description": "Compares how MATLAB conv (full, same, valid) and scipy.signal.convolve (full, same, valid) size their output, with the length each gives for a 7-element first input and a 4-element second input. Compiled from the vendor reference pages for each function.",
  "page": "https://casrai.org/guides/matlab-conv",
  "publisher": "CASRAI",
  "license": "https://creativecommons.org/licenses/by/4.0/",
  "dateModified": "2026-11-16T22:07:42Z",
  "temporalCoverage": null,
  "spatialCoverage": null,
  "columns": [
    {
      "name": "Function and shape",
      "unit": "",
      "description": ""
    },
    {
      "name": "Output length rule",
      "unit": "",
      "description": ""
    },
    {
      "name": "Length for 7-element and 4-element inputs",
      "unit": "elements",
      "description": ""
    },
    {
      "name": "Note",
      "unit": "",
      "description": ""
    }
  ],
  "rows": [
    {
      "Function and shape": "MATLAB conv, full",
      "Output length rule": "length(u)+length(v)-1",
      "Length for 7-element and 4-element inputs": 10,
      "Note": "Default shape"
    },
    {
      "Function and shape": "MATLAB conv, same",
      "Output length rule": "Size of u (central part)",
      "Length for 7-element and 4-element inputs": 7,
      "Note": "Output follows the first input"
    },
    {
      "Function and shape": "MATLAB conv, valid",
      "Output length rule": "max(length(u)-length(v)+1,0); length(u) if length(v) is 0",
      "Length for 7-element and 4-element inputs": 4,
      "Note": "Parts computed without zero-padded edges"
    },
    {
      "Function and shape": "SciPy convolve, full",
      "Output length rule": "N+M-1",
      "Length for 7-element and 4-element inputs": 10,
      "Note": "Default mode"
    },
    {
      "Function and shape": "SciPy convolve, same",
      "Output length rule": "Size of in1 (centred)",
      "Length for 7-element and 4-element inputs": 7,
      "Note": "Output follows the first input"
    },
    {
      "Function and shape": "SciPy convolve, valid",
      "Output length rule": "max(N,M)-min(N,M)+1",
      "Length for 7-element and 4-element inputs": 4,
      "Note": "Differs from MATLAB when the second input is longer"
    }
  ],
  "sources": [
    {
      "title": "MathWorks: conv",
      "url": "https://www.mathworks.com/help/matlab/ref/conv.html",
      "accessed": "2026-11-12"
    },
    {
      "title": "SciPy: scipy.signal.convolve",
      "url": "https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.convolve.html",
      "accessed": "2026-11-12"
    }
  ]
}