Message Boards Message Boards

0
|
5874 Views
|
4 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Please let me know why Mathematica gives error message!

Posted 10 years ago
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] /. %
POSTED BY: Changsoo Lee
4 Replies

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 BY: Changsoo Lee

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.

See http://support.wolfram.com/kb/12502 .

POSTED BY: Bruce Miller
Posted 10 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 BY: Jim Baldwin
Posted 10 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]
POSTED BY: Jim Baldwin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract