Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I want to fit some data to a model. However, if the data involves units in the independent variable, fitting seems not to work. As an example, consider the code

data = Table[{Quantity[t, "d"], Exp[-.1*RandomReal[{.9, 1.1}]*t]}, {t,0, 100}];
nlm = NonlinearModelFit[data, Exp[-a*t], a, t]

The goal is to have parameter estimates with the right units depending on the units appearing in data to minimize the risk of performing incorrect unit conversions manually.

Any suggestions?

share|improve this question
I'm assuming that nlm = NonlinearModelFit[QuantityMagnitude@data, Exp[-a*t], a, t] isn't what you are looking for, but I'm not entirely clear on what you actually want to output. Is the problem that items in data may not have the same units? –  bobthechemist Apr 12 '14 at 12:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.