two outputs of a function

5 ビュー (過去 30 日間)
Catalina Guta
Catalina Guta 2020 年 11 月 13 日
回答済み: Steven Lord 2020 年 11 月 13 日
function [cnt,A] = matrice_nou_vechi(A,noua,veche)
cnt=0;
for row=1:size(A,1)
for col=1:size(A,2)
if(A(row, col)==veche)
A(row,col)=noua;
cnt=cnt+1;
end
end
end
how can i see both "cnt" and matrix "A" when a call the function in command window? (without using disp function)

採用された回答

Stephen23
Stephen23 2020 年 11 月 13 日
[cnt,A] = matrice_nou_vechi([1,2],3,2)
cnt = 1
A = 1×2
1 3
  2 件のコメント
Catalina Guta
Catalina Guta 2020 年 11 月 13 日
the secret is to call the function in this way in the command window?
Stephen23
Stephen23 2020 年 11 月 13 日
編集済み: Stephen23 2020 年 11 月 13 日

サインインしてコメントする。

その他の回答 (1 件)

Steven Lord
Steven Lord 2020 年 11 月 13 日
Your function is defined to return two output arguments. Now you have to call it with two output arguments. I'm assuming you have created variables for the three inputs aready, I'll call them A, x2, and third.
[output1, secondOutput] = matrice_nou_vechi(A, x2, third);

カテゴリ

Help Center および File ExchangeEntering Commands についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by