Reputation: 161
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!
Upvotes: 0
Views: 1727
Reputation: 340
Use the function prod :
vec = 1:4; prod(vec) ans = 24
Upvotes: 2