Replace zeros with non-zero values from another array

25 ビュー (過去 30 日間)
Pelajar UM
Pelajar UM 2022 年 3 月 9 日
回答済み: Arif Hoq 2022 年 3 月 9 日
Output1:
71
0
74
75
85
0
88
Output 2:
39242
32
8385
0
17854
74
10499
I want to take the rows with zero in Output 1 and replace them with values in same rows of Output2.
Output3:
71
32 %This is from Output 2
74
75
85
74
88 %This is from Output 2
Any ideas?

採用された回答

Arif Hoq
Arif Hoq 2022 年 3 月 9 日
output1=[71;0 ;74 ;75 ;85 ;0 ;88 ];
output2=[39242;32;8385 ;0;17854; 74 ;10499];
output1(output1==0)=output2(output1==0);
output3=output1
output3 = 7×1
71 32 74 75 85 74 88

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNaNs についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by