フィルターのクリア

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 Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by