フィルターのクリア

How to suppress the ans in a user defined function

2 ビュー (過去 30 日間)
Alexander
Alexander 2014 年 4 月 16 日
コメント済み: Alexander 2014 年 4 月 16 日
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 件のコメント
Alexander
Alexander 2014 年 4 月 16 日
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 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by