1
$\begingroup$

I have say 10 sets of data, all of which I want to perform a linear fit to using LinearModelFit[...]. Is there a way I can fit multiple data sets quickly rather than writing out LinearModelFit[DataSet1], LinearModelFit[DataSet2],LinearModelFit[DataSet3] and so on. And then ideally extract put the fit results into a list -- something like FitResults={m1,m2,m3...}?

The most obvious way to me is a Do[...] but somehow this seems a bit crude...Any thoughts?

Thanks

$\endgroup$
  • 2
    $\begingroup$ Table[] and Map[] are good. $\endgroup$ – J. M. is away Sep 27 '17 at 12:38
  • $\begingroup$ @J.M. Any change of a quick e.g? I tried TableData = Table[{Data1,Data2,Data3},{i,1}] and then LinearModelFit[TableData,x,x]...no joy! $\endgroup$ – QuantumPenguin Sep 27 '17 at 12:59
  • 1
    $\begingroup$ Could've done Table[LinearModelFit[(* stuff *)], {dat, {Data1, (* stuff *)}}] and joy is more likely to be had. $\endgroup$ – J. M. is away Sep 27 '17 at 13:09
  • $\begingroup$ @J.M. You were indeed correct. I received much joy. Thanks nice solution! $\endgroup$ – QuantumPenguin Sep 28 '17 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.