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일
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 Exchange에서 Debugging 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