Vectorization problem with assignments
2 次查看(过去 30 天)
显示 更早的评论
Good afternoon. I was trying to vectorize the following code in order to make it faster, however I was unable to do so. I can't also imagine about how to do it looking into the MATLAB examples of vectorization MATLAB. I would be very grateful if somebody could give me help about how to do it.
cols = zeros(length(vector1),dims);
for i=1:length(vector1)
cols(i,:) = Vector2(vector1(i),1:dims);
end
Thank you very much.
Marcos
回答(1 个)
Salman Ahmed
2021-11-19
Hi Marcos,
You can use the following to vectorize your loop.
cols = Vector2(vector1,1:dims);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Optimization Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!