# Getting experimental data ready for presentation [closed]

I would like to create a plot for my diploma, but I am having several issues when I attempt to do so.

1. I want to get an approximated plot of two consequences of point (temperature and ration of current factor). If I evaluate something like

ListPlot[Transpose[{time, ration}], Joined -> True, Axes-> True]


I get a curve, but it is not as smooth as I would like it to be.

2. Do You know a method to get the parameters of a function from a sets of points? For example, I know that my function is expected to be const1(1-Exp[-const2*t)], How can I get the constants?

3. How can I plot a theoretical function on the same plot as the experimental dats?

• Many of the commands shown by executing ?*Fit should help, such as FindFit or NonlinearModelFit. Look them up in the documentation, which also shows how to plot them – Michael E2 Dec 24 '16 at 14:20
• what you are after is probably a fit, not interpolation, see NonlinearModelFit – george2079 Dec 24 '16 at 14:20
• I changed the code for your model to const1(1-Exp[-const2*t)]. In case you didn't know, built-in functions begin with a capital, including standard math functions, and function arguments are wrapped in brackets [ ], not parentheses ( ). – Michael E2 Dec 24 '16 at 14:24
• After you find the fit with NonlinearModelFit, you can combine the plots with Show. – corey979 Dec 24 '16 at 14:24
• I strongly urge you learn more from the documentation before asking such general question here. I recommend starting with the two documentation articles Curve Fitting and Create Plots – m_goldberg Dec 25 '16 at 4:11

We do not know what type of data you have. To overcome this issue, I generated some data from your 'expected function'.

Let us first define your expected function in MMA without the arbitrary constants

f[t_] := (1 - Exp[-t])


Now generate a data table which will contain {t,f(t)}

data = Table[{t, f[t]}, {t, 0, 10}];


model = a*(1 - Exp[-b*t]);


where we need to find a and b.

To fit the data to the expected model, we can use one of the two NonlinearModelFit or FindFit as suggested repeatedly in the comments

nlm = NonlinearModelFit[data, model, {a, b}, t,Method -> NMinimize];


or

FF = FindFit[data, model, {a, b}, t, Method -> NMinimize];


Now to know the arbitrary constants a and b,

nlm["BestFitParameters"]


{a -> 1., b -> 1.}

or

FF


{a -> 1., b -> 1.}

Now plotting data vs fit

Show[ListPlot[data, PlotStyle -> {Darker@Red, PointSize[0.03]}],
Plot[nlm[t], {t, 0, 10}]] Finally, you can plot the data and the theoretical function combine like this

Show[ListPlot[data, PlotStyle -> {Darker@Red, PointSize[0.03]}],
Plot[f[t], {t, 0, 10}]]


Edit

The OP has provided some data in two different lists.

currentfn = {1.004144, 1.458798, 1.579908, 1.974147, 2.045930}
time = {114, 171, 228, 365, 502}


Now we need to combine the two lists to make acceptable for NonlinearModelFit

newdata = MapThread[{#1, #2} &, {time, currentfn}]


Finally, fitting the data

nlm = NonlinearModelFit[newdata, model, {a, b}, t, Method -> NMinimize];

nlm // Normal

Show[ListPlot[newdata, PlotStyle -> {Darker@Red, PointSize[0.03]}],
Plot[nlm[t], {t, 114, 502}]] • @AlexandrBolotnikov If you share your data then maybe you will get some help, otherwise it is a guessing game? – zhk Dec 27 '16 at 15:06
• 1)thank You MMM for ur detailed answer 2) my data is 2 list like that currentfn = {1.004144, 1.458798, 1.579908, 1.974147, 2.045930} time = {114, 171, 228, 365, 502} 3)And when I tried to use NonlinearModelFit function with parameters – Alexandr Bolotnikov Dec 27 '16 at 15:08
• with that command NonlinearModelFit[Transpose[{time, currentfn}], a*(1 - E^(-bx)), {a, b}, x] – Alexandr Bolotnikov Dec 27 '16 at 15:13
• I got the next error Unable to solve for the fit parameters; the design matrix is nonrectangular, non-numerical, or could not be inverted. >> – Alexandr Bolotnikov Dec 27 '16 at 15:14
• @MMM his model is model = a*(1 - Exp[- b t]) (Fits much better that way!) – george2079 Dec 27 '16 at 18:04