Change a matrice with a function
古いコメントを表示
Hello
I need some help to change a matrix with a function in a m. file. which is called "add(A,B,I)"
A is the matrix, B is the new values and I is the position
A = [1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16];
B = [99 98; 22 23];
I = [3,2]
The function should return a result that looks like this
[1 2 3 4; 5 6 7 8; 9 99 98 12; 13 21 23 16]
I have tried google to find help with the coding in the m. file. Can anybody help me with this problem?
2 件のコメント
Azzi Abdelmalek
2015 年 8 月 21 日
Can you explain?
the cyclist
2015 年 8 月 21 日
編集済み: the cyclist
2015 年 8 月 21 日
The algorithm to get the result from the input is not clear (at least not to me).
EDIT: I think I figured out what you mean. You want to embed B into A, beginning at the indices defined by I. If that is what you mean, my answer does that.
I suggest you do not call your function "add" which is a MATLAB keyword. Maybe call it "insertSubmatrix" or something like that.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!