Nested loops for double summation

3 Ansichten (letzte 30 Tage)
J.Cam
J.Cam am 14 Mär. 2020
Bearbeitet: J.Cam am 20 Mär. 2020

Antworten (1)

Akira Agata
Akira Agata am 15 Mär. 2020
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(:));

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by