Discussion:
converting table output and plotting
(too old to reply)
seferiad
2004-06-30 09:54:35 UTC
Permalink
Hello,
I have the following equation:

Table[{v, NSolve[{i == v/r2 + i1, i1==i1(r1+r2)/r2 + a/r2*Log[i1/io +
1] - v/r2} /. {r2 -> 200, r1 -> .025, io -> 10^-9, a -> .05}, {i,
i1}]},{v, 1, 1.2, .1}]//ColumnForm


OUTPUT IS:

{1, {{i->.402, i1->.397}}}
{1.1{{i->1.611,i1->1.60}}}
{1.2,{{i->3.86, i1->3.85}}}


The first terms 1, 1.1,1.2 are Voltage (v) and the second term is
Current (i), the third term is Current1 (i1).

My objective is to vary my equation above and then create the output
in such a form that I can directly plot v vs. i, that is "1st term"
vs. "2nd term". Unfortunately, I don't know how to do this since the
outputs in the table aren't as I like.

Note: My original approach was to write the transcendental equation in
a single form whereby, NSolve[ i == function (v, i) ] Unfortunately,
Mathematica seems to choke on this one. By calculating an additional
(uninteresting) value (namely, v1), it gives me the output I'm looking
for. Again, except that I don't know how to convert this into a set of
numbers that I can plot.

Hopefully this makes sense. Any help would be greatly appreciated.
Thanks,
Vince
Paul Abbott
2004-07-01 09:56:35 UTC
Permalink
Post by seferiad
Hello,
Table[{v, NSolve[{i == v/r2 + i1, i1==i1(r1+r2)/r2 + a/r2*Log[i1/io +
1] - v/r2} /. {r2 -> 200, r1 -> .025, io -> 10^-9, a -> .05}, {i,
i1}]},{v, 1, 1.2, .1}]//ColumnForm
{1, {{i->.402, i1->.397}}}
{1.1{{i->1.611,i1->1.60}}}
{1.2,{{i->3.86, i1->3.85}}}
The first terms 1, 1.1,1.2 are Voltage (v) and the second term is
Current (i), the third term is Current1 (i1).
My objective is to vary my equation above and then create the output
in such a form that I can directly plot v vs. i, that is "1st term"
vs. "2nd term". Unfortunately, I don't know how to do this since the
outputs in the table aren't as I like.
Note: My original approach was to write the transcendental equation in
a single form whereby, NSolve[ i == function (v, i) ] Unfortunately,
Mathematica seems to choke on this one. By calculating an additional
(uninteresting) value (namely, v1), it gives me the output I'm looking
for. Again, except that I don't know how to convert this into a set of
numbers that I can plot.
Your set of equations can be solved exactly for i and i1:

solution =
Solve[{i == v/r2+i1, i1==i1(r1+r2)/r2+a/r2 Log[i1/io+1]-v/r2},{i, i1}]

A table of numerical values agrees with those obtained using NSolve:

parameters = {r2 -> 200, r1 -> 0.025, io -> 10^(-9), a -> 0.05};

Table[{v, solution /. parameters}, {v, 1, 1.2, 0.1}]

You can plot the solution v versus i as follows:

ParametricPlot[Evaluate[{i, v} /. solution /. parameters], {v, 1, 2},
AxesLabel -> {i, v}]

(You could just use Plot to visualize i versus v).

Cheers,
Paul
--
Paul Abbott Phone: +61 8 9380 2734
School of Physics, M013 Fax: +61 8 9380 1014
The University of Western Australia (CRICOS Provider No 00126G)
35 Stirling Highway
Crawley WA 6009 mailto:***@physics.uwa.edu.au
AUSTRALIA http://physics.uwa.edu.au/~paul
seferiad
2004-07-02 06:13:31 UTC
Permalink
Paul,
Works great. Thanks (oops about the Solve).

When I try to utilize a single equation with v and i, with no intermediate
i1, I find that Mathematica has trouble. I don't understand this.

Thanks,
Jay
Post by Paul Abbott
Post by seferiad
Hello,
Table[{v, NSolve[{i == v/r2 + i1, i1==i1(r1+r2)/r2 + a/r2*Log[i1/io +
1] - v/r2} /. {r2 -> 200, r1 -> .025, io -> 10^-9, a -> .05}, {i,
i1}]},{v, 1, 1.2, .1}]//ColumnForm
{1, {{i->.402, i1->.397}}}
{1.1{{i->1.611,i1->1.60}}}
{1.2,{{i->3.86, i1->3.85}}}
The first terms 1, 1.1,1.2 are Voltage (v) and the second term is
Current (i), the third term is Current1 (i1).
My objective is to vary my equation above and then create the output
in such a form that I can directly plot v vs. i, that is "1st term"
vs. "2nd term". Unfortunately, I don't know how to do this since the
outputs in the table aren't as I like.
Note: My original approach was to write the transcendental equation in
a single form whereby, NSolve[ i == function (v, i) ] Unfortunately,
Mathematica seems to choke on this one. By calculating an additional
(uninteresting) value (namely, v1), it gives me the output I'm looking
for. Again, except that I don't know how to convert this into a set of
numbers that I can plot.
solution =
Solve[{i == v/r2+i1, i1==i1(r1+r2)/r2+a/r2 Log[i1/io+1]-v/r2},{i, i1}]
parameters = {r2 -> 200, r1 -> 0.025, io -> 10^(-9), a -> 0.05};
Table[{v, solution /. parameters}, {v, 1, 1.2, 0.1}]
ParametricPlot[Evaluate[{i, v} /. solution /. parameters], {v, 1, 2},
AxesLabel -> {i, v}]
(You could just use Plot to visualize i versus v).
Cheers,
Paul
--
Paul Abbott Phone: +61 8 9380 2734
School of Physics, M013 Fax: +61 8 9380 1014
The University of Western Australia (CRICOS Provider No 00126G)
35 Stirling Highway
AUSTRALIA http://physics.uwa.edu.au/~paul
Continue reading on narkive:
Loading...