Combining a matrix with a null matrix

2 ビュー (過去 30 日間)
Arjun Upadhyay
Arjun Upadhyay 2020 年 9 月 1 日
コメント済み: Arjun Upadhyay 2020 年 9 月 3 日
I have a very basic problem. I want to replace some entries of zero matrix with the elements of another non zero matrix. I tried with for loop by using conditional statements. But it didn't work.
x = [1 2 3 4], Y= [0 0 0 0 0 0 0 0 0 0]
desired output
z = [1 2 3 4 0 0 0 0 0 0]
So anyone please help. Thanks in advanced

採用された回答

David Hill
David Hill 2020 年 9 月 1 日
z=Y;
z(1:length(x))=x;
  1 件のコメント
Arjun Upadhyay
Arjun Upadhyay 2020 年 9 月 3 日
I have done this with the the help of conditional statements and for loop. But this is quick and easy solution. Thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by