フィルターのクリア

matrices in function output ?

32 ビュー (過去 30 日間)
Rakesh Praveen
Rakesh Praveen 2011 年 11 月 21 日
コメント済み: RB 2017 年 3 月 20 日
hi, how to store two different matrices as an output parameter of a 'function'.
for example: function[matrix1, matrix2]= input(in1,in2) so matrix1 and matrix2 contain some m*n matrix which i obtain through my logic. how do i put these 2 matrices in my function output ? becoz when i use the above function format, output displays only 1 matrix, ie, in this case matrix1 alone.
thank you.

採用された回答

Walter Roberson
Walter Roberson 2011 年 11 月 21 日
When you invoke the function, you need to provide two variables on output:
[m1, m2] = input(in1, in2);
Note: naming a routine "input" will almost certainly lead to later problems, as "input" is the name of a MATLAB routine.
EDIT: complete example:
>> type rakeshtest
function [matrix1,matrix2] = rakeshtest(in1, in2);
matrix1 = ones(size(in1));
matrix2 = zeros(size(in2));
end
>> [m1,m2] = rakeshtest(rand(3,5),rand(2,4))
m1 =
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
m2 =
0 0 0 0
0 0 0 0
  11 件のコメント
Walter Roberson
Walter Roberson 2017 年 3 月 20 日
See attached.
RB
RB 2017 年 3 月 20 日
Thanks so much. It works perfectly.
Regards, RB

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by