Replace zeros with non-zero values from another array
8 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
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
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!