I have a function that identifies the max value of every column, then every row and the max value of the entire matrix itself.
However, whenever I run the code with a given matrix, it produces ans with the values assigned to every column, how do I suppress this?
This is my code.
function[mc,mr,mm] = MyMax_1(A)
mc = max(A);disp('maxcolumns'),disp(mc)
mr = max(A.');disp('maxrows'),disp(mr.')
mm = max(max(A));disp('maxmatrix'),disp(mm)
end

 채택된 답변

Scott
Scott 2014년 4월 16일
When you call MyMax_1(A), add a semi-colon to the end of that line e.g.
x=[1,2,3;4,5,6];
MyMax_1(x);
maxcolumns
4 5 6
maxrows
3
6
maxmatrix
6

댓글 수: 1

Thank you very much, I kept alternating my code and adding semi-colon to different parts of the code and if wouldn't get rid of that damn ans.
Much appreciated friend!

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

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기

제품

질문:

2014년 4월 16일

댓글:

2014년 4월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by