Results 1 to 4 of 4

Math Help - How to remove an entry from an array in MATLAB?

  1. #1
    Member
    Joined
    Feb 2009
    Posts
    98

    How to remove an entry from an array in MATLAB?

    I want a code in MATLAB that produces A\{4}, where A={3,6,1,-3,4,8} (i.e. I'd like to get {3,6,1,-3,8}).

    I know for instance:
    A=[ 3 6 1 -3 4 8];

    A(5)=[]; produces

    3 6 1 -3 8

    But what should I do if I don't know the index (in this case 5) for the entry '4'; and I want to get
    [ 3 6 1 -3 8]?
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Imo
    Imo is offline
    Newbie
    Joined
    Jun 2012
    From
    Croatia
    Posts
    7

    Re: How to remove an entry from an array in MATLAB?

    I have just started using matlab so have that in mind when u read my answer. Here it goes:make a new vector for examlpe t=[A(1:4) A(6)]

    ...and since ur post dates from 2009, by now u have drop matlab or learn how to use it and u can tell me the answer.
    Last edited by Imo; July 23rd 2012 at 01:38 PM.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Member
    Joined
    Feb 2009
    Posts
    98

    Re: How to remove an entry from an array in MATLAB?

    I have no idea why it says 2009, I posted this about a week or so ago!
    But I figured it out. the code can be:

    A=[ 3 6 1 -3 4 8];
    u=find(A==4);
    A(u)=[]
    Follow Math Help Forum on Facebook and Google+

  4. #4
    MHF Contributor

    Joined
    Apr 2005
    Posts
    15,712
    Thanks
    1472

    Re: How to remove an entry from an array in MATLAB?

    It doesn't say this was posted in 2009. It says that you first joined this forum in 2009.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Matlab - Add/Remove edges in delaunay triangulation
    Posted in the Math Software Forum
    Replies: 1
    Last Post: July 16th 2010, 11:09 PM
  2. Matlab - cell array
    Posted in the Math Software Forum
    Replies: 0
    Last Post: April 3rd 2010, 05:28 AM
  3. Matlab data cleaning - cell array to matrix problem
    Posted in the Math Software Forum
    Replies: 0
    Last Post: March 24th 2010, 09:08 AM
  4. Sorting the all array in MATLAB
    Posted in the Math Software Forum
    Replies: 2
    Last Post: March 13th 2010, 10:53 AM
  5. Multiple array generation in Matlab
    Posted in the Math Software Forum
    Replies: 1
    Last Post: January 29th 2009, 02:01 PM

Search Tags


/mathhelpforum @mathhelpforum