I am working on a Mathematica notebook and making graphs for my lab. I can't make a graph for my linearized data as LinearModelFit
gives equation in z
even though I pass x
as an argument.
linfit = LinearModelFit[data, x, x]
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityI am working on a Mathematica notebook and making graphs for my lab. I can't make a graph for my linearized data as LinearModelFit
gives equation in z
even though I pass x
as an argument.
linfit = LinearModelFit[data, x, x]
Somewhere/sometime before LinearModelFit[data,x,x]
is invoked you must have defined x
as z
. To check if this is the case you can use ValueQ
:
ValueQ[x]
gives True
if a value has been defined for x
, and gives False
otherwise. Alternatively, you can use
?x
which returns
if x
is previously assigned a value, just the first line otherwise.
The following simple examples replicates your case:
x = z;
data = {{0, 1}, {1, 0}, {3, 2}, {5, 4}};
linfit = LinearModelFit[data, x, x]
As a fix, you can use ClearAll
to clear all values, definitions, attributes, messages, and defaults associated with x
before using x
in LinearModelFit
:
ClearAll[x]
linfit = LinearModelFit[data, x, x]
ClearAll[x]
beforelinfit =...
? $\endgroup$ – kglr Sep 26 '18 at 23:51