Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Derek Goring

Posts: 3,919
Registered: 12/7/04
Re: Vectorization in Matlab
Posted: May 1, 2014 4:14 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.