Nested loops for double summation

6 vues (au cours des 30 derniers jours)
J.Cam
J.Cam le 14 Mar 2020
Modifié(e) : J.Cam le 20 Mar 2020

Réponses (1)

Akira Agata
Akira Agata le 15 Mar 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(:));
  1 commentaire
J.Cam
J.Cam le 17 Mar 2020
Yes, thank you it worked out!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by