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: Question on a function with changing sign
Replies: 2   Last Post: Jan 20, 2014 9:25 AM

Advanced Search

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

Posts: 1
Registered: 1/19/14
Question on a function with changing sign
Posted: Jan 19, 2014 11:45 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I am a newbie on MATLAB and start learning it now. I was told that it takes less time on using vector operation than loops. Here is my function,

zi = (-1)^i * x^2

I can do the following:
z = x.^2
but I am wondering how to do this to get the (-1)^i without using a loop.
(for using a loop, that would be easy but I want to try something new.)



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.