Nested loops for double summation

回答(1 个)

How about the following?
% Example of 3-by-3 array n
n = rand(3);
% Calculate R, C, and T
R = sum(n,2);
C = sum(n);
T = sum(R);
% Calculate \chi^2
CR = (C'*R')';
S = ((n - CR/T).^2)./(CR/T);
chi2 = sum(S(:));

类别

帮助中心File Exchange 中查找有关 Loops and Conditional Statements 的更多信息

提问:

2020-3-14

编辑:

2020-3-20

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by