1
$\begingroup$

So i imported a file from excel and viewed it as a grid. but now i need to add groups of 5 elements from the y axis and plot them against every fifth entry from the x axis. Thanks

Edit: Sorry about less datails. (its my first day using mathematica, i have very superficial knowledge only)

So I imported an excel file as

k = Import["\\\\myfiles.campus\\~\\y.xlsx", {"Data", 1, All, {7, 2}}]

then selected the data i needed as

r = k[[67 ;; 1499, All]]

until now i can plot this using listplot.

now that i have the graph, my data looks like:

{{6.91647*10^-7, 61.}, {7.02127*10^-7, 56.}, {7.12606*10^-7, 50.}, 
 {7.23085*10^-7, 48.}, {7.33565*10^-7, 44.}, {7.44045*10^-7, 37.}, 
 {7.54524*10^-7, 34.}}

way more than this.

so now i plot this as

g = ListPlot[k, Joined -> True, PlotRange -> {{.000000691647, .0000156983}, {0, 61}}]

but now i try to fit the function

Fit = NonlinearModelFit[g , aExp[bt] + c, {a, b, c}, t] 

which doesnt go through as i have 0's as my y axis.

So i thought i should bin the data and add them into groups of 5 which should resolve the problem, but cannot do that. Thanks

$\endgroup$

closed as unclear what you're asking by bbgodfrey, m_goldberg, MarcoB, user9660, Sjoerd C. de Vries Nov 5 '15 at 6:41

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – Michael E2 Nov 5 '15 at 2:33
  • $\begingroup$ I'm pretty certain you should not be passing in a ListPlot as your data into NonlinearModelFit. Your code above passes g to NonlinearModelFil and g is a ListPlot not a list of data. Could that be your problem? $\endgroup$ – Edmund Nov 5 '15 at 9:48
1
$\begingroup$

I'm not sure you've given enough information but here's my take:

in = Sort@RandomReal[1, {20, 2}];  (* input *)

original = ListPlot[in, PlotStyle -> ColorData[97, 2]]

Mathematica graphics

grouped = ListPlot@Flatten[
   Thread /@ 
    Transpose@{in[[5 ;; ;; 5, 1]], Partition[in[[All, 2]], 5]},
   1]

Mathematica graphics

Compare:

Show[original, grouped]

Mathematica graphics

$\endgroup$
  • $\begingroup$ I just edited the question to make it clearer, thank you for your help $\endgroup$ – help Nov 5 '15 at 3:27
1
$\begingroup$

The data you have given is clearly insufficient to provide a concrete answer, but here is my attempt:

data = {{6.91647*10^-7, 61.}, {7.02127*10^-7, 56.}, {7.12606*10^-7, 
   50.}, {7.23085*10^-7, 48.}, {7.33565*10^-7, 44.}, {7.44045*10^-7, 
   37.}, {7.54524*10^-7, 34.}}

g = ListPlot[data, Joined -> True]

fit = NonlinearModelFit[data, a Exp[b t] + c, {a, b, c}, t]

fun = Normal[fit]

Show[g, Plot[fun, {t, 6*10^-7, 8*10^-7}]]

This fit seems reasonable since I only have 7 data points. Not sure what you mean by "as i have 0's as my y axis." Also you are feeding the plot (g) into the fitting function. Feed the data instead!

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.