Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Vectorization in Matlab
Replies: 1   Last Post: May 1, 2014 4:14 PM

 Messages: [ Previous | Next ]
 Derek Goring Posts: 3,922 Registered: 12/7/04
Re: Vectorization in Matlab
Posted: May 1, 2014 4:14 PM

On Friday, May 2, 2014 5:33:15 AM UTC+12, Ahsham Ali wrote:
> How to increment a variable by a infinite set of numbers, in Matlab. I'v a variable which I want to increment till the loop ends by 0.1 every time but through set of range. I'm currently doing this by: K=K*0.1; %K = 2 initially but I want this same by Matlab's trick of ranged values like [0.1:0.1:9] where 9 is the loop condination.

Here's one way using logs:
x=[0.1:0.1:9];
lx=log10(x); % Take logs
slx=cumsum(lx); % cumulative sum the logs => cumulative product
xprod=10.^slx; % Anti-log

Date Subject Author
5/1/14 Ahsham Ali
5/1/14 Derek Goring