       Re: importing data from Excel to Mathematica

• To: mathgroup at smc.vnet.net
• Subject: [mg85723] Re: importing data from Excel to Mathematica
• From: "Steve Luttrell" <steve at _removemefirst_luttrell.org.uk>
• Date: Wed, 20 Feb 2008 06:55:43 -0500 (EST)
• References: <fpe06j\$ser\$1@smc.vnet.net>

```I assume you can import your equation string into Mathematica in the form
"x1 = A x2 + B y1\ny1 = C y2 - D x1" where \n is the newline character.

In:= s="x1 = A x2 + B y1\ny1 = C y2 - D x1"
Out= x1 = A x2 + B y1
y1 = C y2 - D x1

The aim now is to manipulate this into the correct form for an algebraic
expression that Mathematica can work with.

Split the above single string into two separate strings.

In:= s2=StringSplit[s,"\n"]
Out= {x1 = A x2 + B y1,y1 = C y2 - D x1}

Replace = (i.e. Set) with == (i.e. Equal) to make the strings have the
correct Mathematica syntax for equations.

In:= s3=StringReplace[s2,"="->"=="]
Out= {x1 == A x2 + B y1,y1 == C y2 - D x1}

Convert the strings to algebraic expressions that Mathematica can manipulate
symbolically.

In:= e=ToExpression[s3]
Out= {x1==A x2+B y1,y1==-D x1+C y2}

Solve the equations.

In:= Solve[e,{x1,y1}]
Out= {{x1->-((-A x2-B C y2)/(1+B D)),y1->-((A D x2-C y2)/(1+B D))}}

Stephen Luttrell
West Malvern. UK

"Tugrul Temel" <temelt at xs4all.nl> wrote in message
news:fpe06j\$ser\$1 at smc.vnet.net...
> Dear All,
>
> I have an Excel database with strings of equations in the following form:
>
> x1 = A x2 + B y1
> y1 = C y2 - D x1
>
> I like to import these equations to Mathematica and solve for x1 and y1:
>
> Which format is the best for importing?
>
> Thanks
>
> Tugrul
>
>
>
>
>
>

```

• Prev by Date: Re: Sterographic display
• Next by Date: Re: Garbage collection and mutable data structuresDavid Bailey,http://www.dbaileyconsultancy.co.uk
• Previous by thread: importing data from Excel to Mathematica
• Next by thread: Localizing Large Numbers of Variables in a DynamicModule: