Nested loops for double summation

4 ビュー (過去 30 日間)
J.Cam
J.Cam 2020 年 3 月 14 日
編集済み: J.Cam 2020 年 3 月 20 日

回答 (1 件)

Akira Agata
Akira Agata 2020 年 3 月 15 日
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 件のコメント
J.Cam
J.Cam 2020 年 3 月 17 日
Yes, thank you it worked out!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by