Multiplying part of vector with another vector repeatedly without for loop
1 次查看(过去 30 天)
显示 更早的评论
I have a very long vector A, and I want to take each 10 elements of it and multiply it element-by-element (.*) by another vector has length 10 called "carrier" without using for loop because it takes very long time. This portion of the code did the required but it takes a very long time so is there any way to do it without for loop?
s = [];
for k2 = 1:length(A)
s = [s sequence(1+(k2-1)*10:k2*10).*carrier];
end
0 个评论
采纳的回答
Kaushik Lakshminarasimhan
2017-11-12
Try using repmat:
s = sequence(:).*repmat(carrier(:),N,1); % N is the no.of 10-element segments in 'sequence'
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!