Passing a matrix to a function and returning
14 ビュー (過去 30 日間)
古いコメントを表示
I wish to pass a matrix A= [ 1 2 3] and B =[2 5 7] to a function in matlab and return its sum A+B. Please help
0 件のコメント
回答 (1 件)
Image Analyst
2014 年 4 月 13 日
In test.m:
function test()
A= [ 1 2 3];
B =[2 5 7]
C = AddTogether(A, B)
function c = AddTogether(a, b)
c = a + b;
Of course it's good to make it more robust with try/catch and checking that the things actually can be added together. I've just given you the bare minimum.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Operating on Diagonal Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!