Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

linalg::nonZeros

Number of non-zero elements of a matrix

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

Syntax

linalg::nonZeros(A)

Description

linalg::nonZeros(A) returns the number of non-zero components of the matrix A.

Examples

Example 1

The matrix

MZ7 := Dom::Matrix(Dom::IntegerMod(7)):
A := MZ7([[18, -1], [4, 81]])

has four non-zero entries:

linalg::nonZeros(A)

The matrix:

B := MZ7([[21, 2], [-1, 14]])

has only two non-zero entries:

linalg::nonZeros(B)

Parameters

A

A matrix of a domain of category Cat::Matrix

Return Values

Nonnegative integer

Was this topic helpful?