Nested loops for double summation

조회 수: 11 (최근 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 CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by