Matrix multiplication with each other.

Hi!
I have a matrix [1 2 3 4 5 6 7 8] and I want to multiply 2 and 2 elements together, so 1*2 and 3*4 and 5*6 etc. What is the command to do so?

Answers (1)

Guillaume
Guillaume on 13 Oct 2017
Edited: Guillaume on 13 Oct 2017
yourvector(1:2:end) .* yourvector(2:2:end)
or
prod(reshape(youvector, 2, []))

This question is closed.

Asked:

213
on 13 Oct 2017

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!