필터 지우기
필터 지우기

Why is the 'sum' function also outputting elements of my matrix?

조회 수: 4 (최근 30일)
Tony
Tony 2016년 3월 6일
댓글: Tony 2016년 3월 6일
I have a column vector that I am trying to take the sum of, but I want it to display only the sum. Every time I use the sum function it also spits out every element in the matrix, along with the sum, which I do not want it to do. This seemed like an easy fix, but I couldn't find anything online.

채택된 답변

John D'Errico
John D'Errico 2016년 3월 6일
Did you write your OWN function called sum? Type this on the command line:
which sum -all
If you have written a function called sum, it will then show up. Delete it, as sum is a tremendously important tool in MATLAB. At the very least rename it, or move it off your search path.
The fact is, sum does NOT do as you describe, so the only way what you describe can happen is if you did exactly what I suggest.
  댓글 수: 1
Tony
Tony 2016년 3월 6일
Wait, I made a dumb mistake. Didn't notice I forgot to suppress output of that matrix in another line of the code. I think after adding the sum(A) part I changed part of my code elsewhere as well leading me to believe the sum-function of Mat lab was glitched. Thanks for a timely response though.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by