Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Problem with function definition inside DynamicModule
Replies: 1   Last Post: Apr 6, 2013 5:10 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Themis Matsoukas

Posts: 320
From: Penn State
Registered: 6/20/10
Re: Problem with function definition inside DynamicModule
Posted: Apr 6, 2013 5:10 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I am not familiar with DynamicModule but here is a way to do the same thing using Manipulate:

showFit[myData_] := Manipulate[
f = Fit[myData, Table[x^k, {k, 0, nn}], x];
Show[
ListPlot[myData,
Joined -> False,
PlotStyle -> {Red, AbsolutePointSize[7]},
PlotRange -> All],
Plot[f, {x, 0, 5}]
], {nn, {1, 2, 3, 4, 5}}
];

data = Table[{x, x^2 + RandomReal[{-1, 1}]}, {x, 0, 5}];
showFit[data]




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.