What's function does replace LINALG::SUBSTITUTE (A,B,m,n)?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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.
0 comentarios
Respuestas (1)
Stephan
el 2 de En. de 2019
Editada: Stephan
el 3 de En. de 2019
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
0 comentarios
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!