필터 지우기
필터 지우기

How to change array element with another array

조회 수: 3 (최근 30일)
Mirza M
Mirza M 2014년 12월 4일
답변: Andrei Bobrov 2014년 12월 4일
hi all, so i have 2 array and i want to change the value of array1 to array2. for example i have:
a = [1 1 1; 1 1 1; 1 1 1]
b = [4 4; 4 4]
and i want the array to be like this :
c = [4 4 1; 4 4 1; 1 1 1]
basicaly i want 'b' to be inside 'a' and replace all element 'a' in the same position as 'b' hehe what is the simplest code for this? thanks

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 12월 4일
a = [1 1 1; 1 1 1; 1 1 1]
b = [4 4; 4 4]
[n,m]=size(b)
a(1:n,1:m)=b

추가 답변 (1개)

Andrei Bobrov
Andrei Bobrov 2014년 12월 4일
n = size(b);
c = a;
c(1:n(1),1:n(2)) = b;

카테고리

Help CenterFile Exchange에서 NaNs에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by