On 1/28/04 at 5:19 AM, mtmtk2003 at yahoo.com (mtmtk) wrote:
>I have this table:
>Table[{((6.67/10^8)*157.85)/(0.225 - x)^2, (Pi^2/420^2)*x}, {x, 0.,
>0.007245, 0.001}]
>I wanted to plot the difference of each pair but the only solution
>I could find was to first have two tables A and B then take A-B and
>try to plot that.
>A = Table[{((6.67/10^8)*157.85)/(0.225 - x)^2}, {x, 0., 0.007245,
>0.001}]
>B = Table[{(Pi^2/420^2)*x}, {x, 0, 0.007245, 0.001}]
>A - B
>{{0.00020797224691358022}, {0.0002097773366920289},
>{0.00021160751897569133}, {0.00021346324689854517},
>{0.00021534498386961064}, {0.0002172532038538137},
>{0.00021918839166184726}, {0.00022115104324936126}}
>But ListPlot will give an error for this :
>"...is not a list of numbers or pairs of numbers."
>When I delete the curly braces around the numbers then ListPlot
>works.
>But this is too complicated for plotting the difference of two sets
>of numbers.
>How can this be done simply? Thanks for any help.
There are a number of ways this can be solved. First, you could get rid of the curly braces in your definition of A and B. That is defining
A = Table[((6.67/10^8)*157.85)/(0.225 - x)^2, {x, 0., 0.007245,0.001}]
B = Table[(Pi^2/420^2)*x, {x, 0, 0.007245, 0.001}]
Now both A and B will be vectors as will be A-B and ListPlot will not complain.
However, to me the simplest is to work directly with the initial table. That is
data=Table[{((6.67/10^8)*157.85)/(0.225 - x)^2, (Pi^2/420^2)*x}, {x, 0.,0.007245, 0.001}];
ListPlot[Subtract@@@data];
But using your definition of A and B
ListPlot[Flatten[A-B]];
will work just fine. This is nothing more than removing one level of curly braces which you describe as "too complicated". I wonder what you are doing when you "delete the curly braces" that you find "too complicated".
--
To reply via email subtract one hundred and four