# corrcoeff (MathScript RT Module Function)

LabVIEW 2012 MathScript RT模块帮助

»查看产品信息

Owning Classes: spectral analysis and statistics

Requires: MathScript RT Module

## Syntax

r = corrcoeff(x)

r = corrcoeff(x, y)

[r, p, rlo, rup] = corrcoeff(x, 'alpha', a, 'rows', s)

[r, p, rlo, rup] = corrcoeff(x, y, 'alpha', a, 'rows', s)

Legacy Name: `corrcoef`

## Description

Computes the correlation coefficients.

Details

Examples

## Inputs

Name Description
x Specifies observations for each variable. If you specify r = corrcoeff(x), x can be real or complex. If you specify [r, p, rlo, rup] = corrcoeff(x, 'alpha', a, 'rows', s), x must be real. x is a vector or matrix. If x is a vector, each element in x is an observation. If x is a matrix, each row in x is an observation, and each element in the row is data for that observation.
y When x is a vector, y specifies the data values for each observation in x. When x is a matrix, you cannot specify y. y is an array of the same length as x.
'alpha' Tells LabVIEW that the next listed input is a.
a Specifies the confidence level 1-a. a is a real number in the interval [0, 1]. The default is 0.05.
'rows' Tells LabVIEW that the next listed input is s.
s Specifies how to handle values of NaN in x. s is a string that accepts the following values.

 'all' (default) Uses all data to compute the correlation coefficients. 'complete' Uses only rows without values of NaN to compute the correlation coefficients. 'pairwise' Uses only rows without values of NaN in the i-th and j-th columns of x to compute the (i, j)-th element of r.

## Outputs

Name Description
r Returns the correlation coefficients.
p Returns the p-values for the null hypothesis. p is a matrix.
rlo Returns the lower bound for the confidence interval of each coefficient. rlo is a matrix.
rup Returns the upper bound for the confidence interval of each coefficient. rup is a matrix.

## Details

If you specify both inputs x and y, LabVIEW computes the correlation coefficients according to the following equation: r = corrcoeff([x(:), y(:)]).

The following table lists the support characteristics of this function.

 Supported in the LabVIEW Run-Time Engine Yes Supported on RT targets Yes Suitable for bounded execution times on RT Not characterized

## Examples

R = corrcoeff(rand(5, 6))

R = corrcoeff(rand(5, 1), rand(5, 1))

[R, P, RLO, RUP] = corrcoeff(rand(5, 6))

﻿