How to replace middle value of matrix 4x4 with the other matrix 2x2?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have matrix A with size 4x4, and I want to replace the middle value of matrix A(size 2x2) with matrix B, the matrix B have size 2x2. Thanks.
0 Kommentare
Antworten (1)
Wayne King
am 6 Feb. 2014
Bearbeitet: Wayne King
am 6 Feb. 2014
A = randn(4,4);
B = randi([0 1],2,2);
A([6 7 10 11]) = B;
I determined those linear indices using:
sub2ind([4 4],[2 2 3 3],[2 3 2 3])
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!