필터 지우기
필터 지우기

How to replace middle value of matrix 4x4 with the other matrix 2x2?

조회 수: 3 (최근 30일)
Andi Tarigan
Andi Tarigan 2014년 2월 6일
댓글: Andi Tarigan 2014년 2월 6일
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.

답변 (1개)

Wayne King
Wayne King 2014년 2월 6일
편집: Wayne King 2014년 2월 6일
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])
  댓글 수: 1
Andi Tarigan
Andi Tarigan 2014년 2월 6일
Thanks. And what if I have a matrix A (4x4) with a size of (1x64 cell), and the matrix B (2x2) with size of (1x64 cell)? And I want to replace all of the matrix A.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by