Insert values of one vector at specific places into another
1 次查看(过去 30 天)
显示 更早的评论
Hello MATLAB-Community,
I'm stuck with the following problem:
If got two vectors, a and b.
a = [0 0 0 0 1 0 0 0 1 0 1 0 0 0 1 0 0 1 0];
b = [ 10 20 30 40 50 ]
Can somebody give ma a hint, how I best merge these two into
c=[0 0 0 0 10 0 0 0 20 0 30 0 0 0 40 0 0 50 0]
Thank you in advance for your help!
Christian
0 个评论
采纳的回答
Turlough Hughes
2021-8-24
a = [0 0 0 0 1 0 0 0 1 0 1 0 0 0 1 0 0 1 0];
b = [ 10 20 30 40 50 ];
c = zeros(size(a));
c(logical(a)) = b
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!