This example shows how to call the Python math.fsum
function, which sums the floating-point values in an interable
input argument.
Open the MATLAB® patients.mat
data file and read the numeric array Height
.
load patients.mat
class(Height)
ans = 1×6 char array double
MATLAB automatically converts the numeric values to Python numeric values. However, Height
is a 100-by-1 array, and MATLAB must pass a 1-by-N array to a Python iterable
argument.
size(Height)
ans = 100 1
Transform Height
to a 1-by-N matrix before calling fsum
.
py.math.fsum(Height')
ans = 6707