# Please let me know why Mathematica gives error message!

Posted 9 years ago
4830 Views
|
4 Replies
|
3 Total Likes
|
 lst = { {100, 0}, {110, 25}, {120, 30}, {130, 50}, {140, 70}, {150, 60}, {160, 50}, {170, 40}, {160, 30}, {150, 20}, {140, 10}, {130, 0} }; lngth = Length[lst]; ListPlot[lst, AxesOrigin -> {0, 0}] Range[lngth]; Transpose[{%, lst}] lstInt = Interpolation[%] Plot[lstInt[x][[1]], {x, 1, lngth}] Plot[lstInt[x][[2]], {x, 1, lngth}] Show[ ListPlot[lstInt[#] & /@ Range[lngth], AxesOrigin -> {0, 0}, PlotStyle -> {Green}], ListPlot[lstInt[#] & /@ (Range[lngth - 1] + 0.2), AxesOrigin -> {0, 0}, PlotStyle -> {Red}], ParametricPlot[{lstInt[x][[1]], lstInt[x][[2]]}, {x, 1, lngth}, AspectRatio -> 0.5] ] FindRoot[lstInt[x][[2]] == 20, {x, lngth}] lstInt[x] /. % 
4 Replies
Sort By:
Posted 9 years ago
 Thank you for all your response.I can plot lstint[x][[1]] or lstint[x][[2]] without errors. I hope Wolfram to improve the functionality of ParametricPlot, FindRoot, and NSolve.
Posted 9 years ago
 FindRoot is evaluating its first argument before inserting a number for x. Either ignore the warning or convert lstInt into a function that is inert for non-numerical arguments.
Posted 9 years ago
 I now see that I haven't solved what I think is the remaining issue with FindRoot[lstInt[x][[2]] == 20, {x, lngth}] Sorry. I don't know how to fix that.
Posted 9 years ago
 Pasting code in using the "Code Sample" icon (leftmost icon on the set of formatting tools) will allow folks to paste in code much, much easier and more importantly will increase the chances of getting a response (and a correct response at that).It appears that the error is generated from ParametricPlot[{lstInt[x][[1]], lstInt[x][[2]]}, {x, 1, lngth}, AspectRatio -> 0.5] The function lstInt is has two output dimensions so that you don't need to explicitly split things up. The following replacement code should work: ParametricPlot[lstInt[x], {x, 1, lngth}, AspectRatio -> 0.5]