# How to remove an entry from an array in MATLAB?

• Jul 17th 2012, 04:50 PM
math8
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]? http://www.physicsforums.com/Prime/buttons/report.gif http://www.physicsforums.com/Prime/buttons/quote.gif
• Jul 23rd 2012, 02:35 PM
Imo
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)] :D

...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.
• Jul 25th 2012, 10:55 AM
math8
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)=[]
• Jul 25th 2012, 12:49 PM
HallsofIvy
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.