필터 지우기
필터 지우기

how to store data at non zero place of matrix

조회 수: 1 (최근 30일)
Nilesh Mate
Nilesh Mate 2017년 11월 1일
댓글: Jan 2017년 11월 3일
I have following column vector A=[0;25;35;0;-65;0] Now at place of non zero coefficient of A, I have replace it with following column vector values. B=[48.23;-57.23;-100.29] So the final matrix will be A=[0;48.23;-57.23;0;-100.29;0]

채택된 답변

Birdman
Birdman 2017년 11월 1일
편집: Birdman 2017년 11월 1일
ind=find(A~=0)
A(ind)=B
  댓글 수: 1
Jan
Jan 2017년 11월 3일
The editor should show a mark, that this code could be improved: Simply omit the find to apply a faster "logical indexing":
A(A ~= 0) = B

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by