Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5669
| From | Bill Rowe <readnews@sbcglobal.net> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Only real data |
| Date | 2011-10-16 11:10 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j7ee3c$eie$1@smc.vnet.net> (permalink) |
On 10/15/11 at 6:03 AM, HB-Kowalczyk-Schroeders@t-online.de (J=C3=B6rg
Schr=C3=B6der) wrote:
>I have a problem to exclude complex solutions. I tried
>data1={2,3/4,1.3,=E4}
>{2,3/4,1.3,=E4}
>Cases[data1, Except[_Complex]]
>{2,3/4,1.3}
>and got, what I expected. But when I have data like
>{0,0,-I Sqrt[3],I Sqrt[3]}
>The above doesn't work. Is this due to a different Head? Is there an
>easy way to filter the non-complex data?
Yes, the issue is
In[21]:= Head[I Sqrt[3]]
Out[21]= Times
You can filter out anything with a complex value with FreeQ as follows:
In[22]:= Cases[{0, 0, -I Sqrt[3], I Sqrt[3]}, _?(FreeQ[#,
_Complex] &)]
Out[22]= {0,0}
=46reeQ[expr, pattern] returns True when any subexpression of expr
matches pattern
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: Only real data Bill Rowe <readnews@sbcglobal.net> - 2011-10-16 11:10 +0000
csiph-web