필터 지우기
필터 지우기

how to sum of column without sum function in a unit metrix

조회 수: 6 (최근 30일)
MD Anower Hossain
MD Anower Hossain 2019년 9월 21일
댓글: Matt J 2019년 9월 21일
x1 = [1 2 3; 4 5 6; 7 8 9];
all =(x1);
summa=0;
count = 0;
for i=1:length(all)
% fprintf("%d\n",i);
summa = 0;
for j = 1:length(all)
summa = summa + all(j);
% fprintf("%d ",j);
end
fprintf("%d ",summa);
end
I want to sum every column without sum function , i tried it but i can't can anyone help me please ?

채택된 답변

Matt J
Matt J 2019년 9월 21일
summa = summa + all(j,i);
  댓글 수: 2
MD Anower Hossain
MD Anower Hossain 2019년 9월 21일
can you please describe it why you use all(j,i); why j and i ? i used only j .
Matt J
Matt J 2019년 9월 21일
Without this, "i" is not used anywhere. Why did you include a loop over "i" if you are not going to use it?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by