multiplying adjacent values in matrix
16 次查看(过去 30 天)
显示 更早的评论
How do you multiply adjacent values within a single matrix in matlab? My matrix is compiled with the prime numbers before 100. ie. primes(100), if the first values are 2 3 5 7 and i need to multiply 2*3 3*5 5*7 and so on.. thanks!
0 个评论
采纳的回答
Jonathan
2011-11-11
See if this works for you.
A = primes(100);
B = A(1:end-1) .* A(2:end);
2 个评论
Hector Koch
2016-3-31
Could you give insight on how this exactly works? Is it possible to use a loop here as well?
更多回答(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!