Group Abstract Group Abstract

Message Boards Message Boards

0
|
1.4K Views
|
7 Replies
|
2 Total Likes
View groups...
Share
Share this post:

How to delete all instances of -1 from a table?

Posted 8 months ago
POSTED BY: Chris Agee
7 Replies
Posted 8 months ago

Finally figured it out, all I had to do was use the Round function on both components of f and it works perfectly. Have to admit I did it more out of desperation than anything i wasn't expecting that to work

POSTED BY: Chris Agee
DeleteCases[f, _?(Re[#] == -1 &)]
Posted 8 months ago

nvm

POSTED BY: Eric Rimbey
Posted 8 months ago

Thanks for all of your suggestions I figured out what I was doing wrong, f is the quotient of two complex numbers I was only looking at the real portion and ignoring the unreal part, so in most cases I wasn't getting -1 or even +1.

POSTED BY: Chris Agee

Another way:

DeleteCases[{1, 1, -1, 1, -1, -1, 1, -1}, -1]
POSTED BY: Gianluca Gorni

From your description, I assume your f table looks something like this:

{1, 1, -1, 1, -1, -1, 1, -1}

If I use DeleteElements[] on it as follows, I get the desired result:

DeleteElements[{1, 1, -1, 1, -1, -1, 1, -1}, {-1}]
(*  {1, 1, 1, 1} *)

It looks like your DeleteElements[] code does not end in {-1}]. Rather, you seem to have put the {-1}] in the middle of the Table[] code. This is probably the problem, unless there is a problem with f or e, which you did not show.

POSTED BY: Michael Rogers
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard