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

1 次查看(过去 30 天)
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
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

类别

Help CenterFile Exchange 中查找有关 Chemistry 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by