How to transfer value of a array to another array?

조회 수: 1 (최근 30일)
yue ishida
yue ishida 2011년 11월 17일
I have a problem to solve. How we can transfer value of one array to another array? For example,the sample code are as below:
a=zeros(2,5)
a(1,2)=2;a(1,4)=6;a(2,1)=8;a(2,3)=2
b(1,1)=1;b(1,2)=4;b(1,3)=1;b(2,1)=9;b(2,2)=1;b(2,3)=9
So, I want the value from array b will replace the 0 value in array a? How can I do it? I hope I can get help to do this.

채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 11월 17일
Depending on the order you want,
a(a==0)=b(:)
or
b=b.';
a(a==0)=b(:)
  댓글 수: 1
yue ishida
yue ishida 2011년 11월 17일
Thank you very much! You're very helpful...

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by