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: deleting elements from vector
Replies: 3   Last Post: Dec 25, 2012 11:42 PM

Advanced Search

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

Posts: 13
Registered: 12/20/12
Re: deleting elements from vector
Posted: Dec 25, 2012 11:42 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Roger Stafford" wrote in message <kbbkk3$98l$1@newscl01ah.mathworks.com>...
> "Shobana " <manoharanshobana@ymail.com> wrote in message <kbbjar$5g6$1@newscl01ah.mathworks.com>...
> > for j =1:length(e)
> > if(e == 0)
> > data[j] = [];
> > end
> > end

> - - - - - - - - - -
> To make that for-loop work you would have to scan backwards through the data array:
>
> n = length(e);
> for j = n:-1:1
>
> However, Nasser's way is better:
>
> a(e==0) = [];
>
> Roger Stafford


thanks a lot



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.