multiplying adjacent values in matrix

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!

 採用された回答

Jonathan
Jonathan 2011 年 11 月 11 日

0 投票

See if this works for you.
A = primes(100);
B = A(1:end-1) .* A(2:end);

2 件のコメント

lachelle
lachelle 2011 年 11 月 11 日
thank you so much!
Hector Koch
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 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

質問済み:

2011 年 11 月 11 日

コメント済み:

2016 年 3 月 31 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by