A very basic question but puzzled me for long time on how to assign array to variables. For instance, we have array {{t1,x1},{t2,x2}...{tn,xn}} how to assign the first element to variable t and second to variable x so I can do fitting for x=f(t)?
1 Answer
$\begingroup$
$\endgroup$
2
myData = {{t1,x1},{t2,x2},{t3,x3}};
{t,x} = Transpose[myData];
t
{t1,t2,t3}
But are you seeking myFit = Fit[myData, {t^3, t^2, t, 1}, x]
(for instance)?
-
$\begingroup$ Thanks for your help. that works! And yes I am looking for findfit with known expression but unknown parameters. Because the expression involves integration from 0 to current value of x, that causes trouble. $\endgroup$ Commented Dec 9, 2014 at 0:51
-
$\begingroup$ But thanks for your help, it solves my data handling problem. $\endgroup$ Commented Dec 9, 2014 at 1:06