MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Mathematica plot not matching up to excel plot tia sal22

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102872] Re: Mathematica plot not matching up to excel plot tia sal22
  • From: ADL <alberto.dilullo at tiscali.it>
  • Date: Tue, 1 Sep 2009 03:50:58 -0400 (EDT)
  • References: <h7g91i$6sl$1@smc.vnet.net>

Dear Rick,
first of all, since your data sampling (x values) are not evenly
spaced, you should not use a fit but a linear interpolation.
Then, you must be sure that the end points of each interval overlap.
I past here below a code that works:


data=ImportString["0.0982924752363772\t0.0344262295081967
0.0986084393351466\t0.0098360655737705
0.1155140401157760\t0.0163934426229508
0.1164748651320180\t0.0075409836065574
0.1386068062622770\t0.0009836065573771
0.1395435409178580\t0.0006065573770492
0.1428992013665070\t0.0016393442622951
0.1436297732513820\t0.0034426229508197
0.1457015442681930\t0.0004426229508197
0.1480626531956750\t0.0009672131147541
0.1482226639070100\t0.0049180327868853
0.1524156545756720\t0.0104918032786885
0.1530141098510300\t0.0014098360655738
0.1575534945477170\t0.0163934426229508
0.1576676067824250\t0.0027868852459016
0.1611404224587080\t0.0052459016393443
0.1670225277837930\t0.0080327868852459
0.1680913790488920\t0.0015901639344262
0.1704907789706870\t0.0540983606557377
0.1730613472445450\t0.0032786885245902
0.1742227562111290\t0.0049180327868853
0.1768308547310680\t0.0786885245901639
0.1770892555469960\t0.0160655737704918
0.1833030471009660\t0.0129508196721311
0.1846057016558450\t0.0021311475409836
0.1846072231523070\t0.0180327868852459
0.1929485739267240\t0.0426229508196721
0.2014430886783930\t0.0540983606557377
0.2032650806925650\t0.0573770491803279
0.2048679772160980\t0.0083606557377049
0.2048705130435360\t0.0737704918032787
0.2160811525640010\t0.9672131147540980
0.2221742387319240\t0.2459016393442620
0.2267909661654690\t1.0000000000000000
0.2325942072572340\t0.2950819672131150
0.2335124303725180\t0.0852459016393443
0.2542004713596040\t0.3114754098360660
0.2567122084369010\t0.0786885245901639
0.2567170265090330\t0.4262295081967210
0.3404173363364290\t0.0475409836065574
0.3445755861691910\t0.6229508196721310
0.3449374487445880\t0.1377049180327870
0.3488996791163960\t0.0934426229508197
0.3726375597631130\t0.9016393442622950
0.4193150425790790\t0.0134426229508197
0.4314030783930770\t0.0245901639344262
0.5108163183538630\t0.0124590163934426
0.5786273870377630\t0.0144262295081967
0.5843629215369350\t0.0180327868852459
0.5921370077134800\t0.0639344262295082
0.6151367089930080\t0.0721311475409836
0.6182755561957110\t0.0139344262295082
0.6534964242297300\t0.0145901639344262
0.6535273613244730\t0.0081967213114754
0.7434554097567480\t0.0111475409836066
0.7635751718149880\t0.0459016393442623
0.7851302122031120\t0.0100000000000000
0.8852484831948180\t0.0180327868852459
0.9164695906109470\t0.0031147540983607
0.9937390420556840\t0.0000327868852459
0.9999274753352740\t0.0000327868852459
1.0000000000000000\t0.0000163934426230
","TSV"];

gdata = ListLinePlot[data, PlotRange -> {{0, 1}, All},
  PlotStyle -> Red, PlotMarkers -> Automatic];

pdata = Sort /@ Partition[data, 3, 2];

ranges = {Min[First /@ #], Max[First /@ #]} & /@ pdata;

functions = Interpolation[#, InterpolationOrder -> 1] & /@ pdata;

piecewisefunc = Piecewise[
  MapThread[{#1[x], #2[[1]] <= x <= #2[[2]]} &, {functions, ranges}]];

gfunc = Plot[piecewisefunc, {x, 0, 1}, PlotRange -> {{0, 1}, All},
 MaxRecursion -> 10];

Show[gdata, gfunc]


and you will see that the two plots are exactly equal.

Regards

ADL


On Aug 31, 12:35 pm, Rick T <ratull... at gmail.com> wrote:
> Mathematica plot not matching up to excel plot tia sal22
>
> Greetings All
>
> I have a set of data values I plot in excel then I create a polynomial
> so it can be plotted in mathematica.  Then I create an audio file using
> the piecewise function in mathematica.  The problem I'm having is when
> I compare the excel plot and the mathematica plot they don't match up.
> ...
>
> tia sal22



  • Prev by Date: Re: Coupled Diff Eqs or Poisson Eq, is symbolic solution
  • Next by Date: Re: Mathematica plot not matching up to excel plot tia sal22
  • Previous by thread: Re: Mathematica plot not matching up to excel plot tia sal22
  • Next by thread: Re: Mathematica plot not matching up to excel plot tia sal22