populate matrix columns based on a vector of index vector
8 次查看(过去 30 天)
显示 更早的评论
I generate an 8x8 A matrix below. I also have an 8x1 vector B containing random integer numbers from 1 to 8. And, I have an 8x1 C vector containing numbers obtained below. How can I, for all rows of A, populate those columns of A starting at B to the end, with values of corresponding rows in C without going through a loop (i.e. vectorized).
A=rand(8);
B = randi([1 8], 8, 1);
C=-linspace(8,30,8)';
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!