How do I product elements of a vector?

조회 수: 2 (최근 30일)
cfjunior
cfjunior 2013년 10월 22일
댓글: cfjunior 2013년 10월 22일
Hi,
I have this matrix (3000 by 2) and I want the product of a range of elements in the second column. All of the elements are equal to 0.99 in a initial stage, but its gonna change after some further steps. I tried to use 'prod' but it didn't work...
Ex. matrix named 'aux'
prod(aux(2500,2):aux(2700,2)); It always returns me 0.99 no matter the range...
How do I do it?
tks
  댓글 수: 3
cfjunior
cfjunior 2013년 10월 22일
or example:
A = [71 2; 72 2; 73 2; 74 2; 75 2];
and I want the product of the second element till fourth element (in sequence)
so, I want 2 x 2 x 2 = 8 ...
cfjunior
cfjunior 2013년 10월 22일
I got it, thanks!

댓글을 달려면 로그인하십시오.

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 10월 22일
편집: Azzi Abdelmalek 2013년 10월 22일
A = [71 2; 72 2; 73 2; 74 2; 75 2];
prod(A(2:4,2))

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by