What's function does replace LINALG::SUBSTITUTE (A,B,m,n)?

I'm searching for matlab function which replaces linalg::substitute (A,B,m,n); it allows me replace a part of original matrix A, with a submatrix B, starting from A raw m and A column n.
Thank you.

回答 (1 件)

Stephan
Stephan 2019 年 1 月 2 日
編集済み: Stephan 2019 年 1 月 3 日

1 投票

Hi,
you can use this function:
function result = linalg_substitute(A,B,m,n)
[mA, nA] = size(A);
[mB, nB] = size(B);
result = A;
if mB+m-1 > mA || nB+n-1 > nA %Ignore values out of range
return
else
result(m:mB+m-1, n:nB+n-1) = B;
end
end
Result is for example:
>> A = zeros(5)
A =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
>> B = ones(3)
B =
1 1 1
1 1 1
1 1 1
>> C = linalg_substitute(A,B,2,2)
C =
0 0 0 0 0
0 1 1 1 0
0 1 1 1 0
0 1 1 1 0
0 0 0 0 0
Simply save the function as linalg_substitute.m in your Matlab path. Then you can use it always you need it.
Best regards
Stephan

カテゴリ

ヘルプ センター および File ExchangeDebugging and Improving Code についてさらに検索

質問済み:

2019 年 1 月 2 日

編集済み:

2019 年 1 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by