0

If I have:

vec = 1:10 

is there a function that will multiply all elements together (1*2*3*4*5...) of it without the need of a for loop?

Thanks!

2
  • 4
    Hmmm, did you search the documentation for a function to evaluate the product of a vector or would you like me to do that for you ? Commented Oct 14, 2013 at 3:34
  • 1
    Please don't forget that not everyone is a native English speaker. The word "product" is different than the word "multiply". Commented Oct 14, 2013 at 8:45

1 Answer 1

2

Use the function prod :

vec = 1:4; prod(vec) ans = 24 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.