Plotting after solving equations

I obtained a list of Y list after using Table[NSolve[expression,X],{var,varmin,varmax,step}]. Then I created a list of X with Range. I concatenated both of these lists and took the transpose to get x,y points. I need to plot the two lists. I think I am getting issue because of the X-> obtained in the list. Can anyone tell how to get rid of X-> in the list. It seems something trivial but I don't seem to know it.

Some points of the list {{0.1,X->0.333333}, {0.2,X->0.5}, {0.3,X->0.6}, {0.4,X->0.666667}} .

Code

expression = k1 *kinase *(Xtot - X) - k11 *phase* X == 0;
phase = 0.2; k1 = 1; k11 = 1; Xtot = 1;
Yvalues = Table[NSolve[expression, X], {kinase , 0.1, 2, 0.1}] // Flatten;
Xvalues = Range[0.1, 2, 0.1];
Finallist = Transpose[{Xvalues,Yvalues}]
ListPlot[Finallist]


If anyone knows a better way to plot it would be much better.

• Change the definition of Yvalues to Yvalues = Table[X /. NSolve[expression, X], {kinase, 0.1, 2, 0.1}] // Flatten; Commented Mar 6, 2021 at 19:05
• See also Values Commented Mar 7, 2021 at 5:47

This will do it for you

    expression = k1*kinase*(Xtot - X) - k11*phase*X == 0;
phase = 0.2; k1 = 1; k11 = 1; Xtot = 1;
Yvalues =
Table[X /. NSolve[expression, X], {kinase, 0.1, 2, 0.1}] // Flatten;
Xvalues = Range[0.1, 2, 0.1];
Finallist = Transpose[{Xvalues, Yvalues}];
ListPlot[Finallist]
ListLinePlot[Finallist]


You need to look up ReplaceAll to get rid of the X-> The output is in this form to prevent X being set to a numerical value. Also note that it is best to use lower case variables since these won't clash with Mathematica variables.

• Thanks. Do you know how to get a line connecting all these points?
– A Q
Commented Mar 6, 2021 at 19:07
• See edit.......
– Hugh
Commented Mar 6, 2021 at 19:10

Try this:

expression = k1*kinase*(Xtot - X) - k11*phase*X == 0;
phase = 0.2; k1 = 1; k11 = 1; Xtot = 1;
Yvalues =
Table[Solve[expression, X], {kinase, 0.1, 2, 0.1}] // Flatten;
Xvalues = Range[0.1, 2, 0.1];
finallist = Transpose[{Xvalues, Yvalues}] /. {a_, X -> b_} -> {a, b}

(*
{{0.1, 0.333333}, {0.2, 0.5}, {0.3, 0.6}, {0.4, 0.666667}, {0.5,
0.714286}, {0.6, 0.75}, {0.7, 0.777778}, {0.8, 0.8}, {0.9,
0.818182}, {1., 0.833333}, {1.1, 0.846154}, {1.2, 0.857143}, {1.3,
0.866667}, {1.4, 0.875}, {1.5, 0.882353}, {1.6, 0.888889}, {1.7,
0.894737}, {1.8, 0.9}, {1.9, 0.904762}, {2., 0.909091}}
*)


Then

ListPlot[finallist]


yielding this:

Have fun!

• By the way, you could make your final list in a more concise way: finallist = Table[{kinase, Solve[expression, X][[1, 1, 2]]}, {kinase, 0.1, 2, 0.1}]. Commented Mar 6, 2021 at 19:48

Your problem can be solved exactly.

expression = k1*kinase*(Xtot - X) - k11*phase*X == 0;
phase = 1/5; k1 = 1; k11 = 1; Xtot = 1;


As with the other solutions, using ReplaceAll

x[kinase_] = X /. Solve[expression, X][[1]]

(* (5 kinase)/(1 + 5 kinase) *)

Plot[x[kinase], {kinase, 0, 2},
AxesLabel -> {"kinase", "X"},
PlotRange->All] (* EDIT: Added PlotRange -> All *)


We can directly use ContourPlot to plot the solution of the equation k1*kinase*(Xtot - X) - k11*phase*X.

phase = 0.2; k1 = 1; k11 = 1; Xtot = 1;
ContourPlot[
k1*kinase*(Xtot - X) - k11*phase*X == 0, {kinase, 0.1, 2}, {X, 0.1,
2}]