-2
$\begingroup$

Continuation Manipulate function to generate outliers

I want to call a function in the manipulate environment so that the changing data is fed to another function and both the plots are plotted in a superimposed fashion. This is what i did.

lsqcurve[data_, degree_] := 
   Module[{m, knot, vandermonde, bez, dplot, bezpolyplot, n}, 
   m = Length[data] - 1;
   n = degree;
   knot = Table[t, {t, 0.0, 1.0, 1/m}];
   vandermonde = 
   Table[BernsteinBasis[n, j - 1, knot[[i]]], {i, 1, m + 1}, {j, 1, 
   n + 1}];
   bez = LinearSolve[Transpose[vandermonde].vandermonde, 
   Transpose[vandermonde].data];
   Return[bez];]
n = 100;
data3 = Table[{t, t^2 + 0.4 RandomReal[]}, {t, 0.0, 10.0, 10/n}];

point = Part[data3, 50];
Manipulate[ListPlot[ReplacePart[data3, {50, 2} -> i]], {i, 0.`, 100},lsqcurve[data3,5]]

This is not giving expected output

$\endgroup$
1
  • $\begingroup$ can someone remove hold on this please..The question is answered now $\endgroup$ Commented Mar 8, 2016 at 2:26

1 Answer 1

0
$\begingroup$
Manipulate[ListLinePlot[{#, lsqcurve[#, 5]}, Mesh -> All] &@
                                            Join[data3[[;; -2]], {{data3[[-1, 1]], i}}], 
          {i, 0, 100}]  

enter image description here

$\endgroup$
5
  • $\begingroup$ hi @Dr.belisaurus...now the point is not getting displayed....where should i add the releevant code to display the points... $\endgroup$ Commented Mar 5, 2016 at 8:43
  • $\begingroup$ @kranthikumar Add the option Mesh -> All to ListLinePlot $\endgroup$ Commented Mar 5, 2016 at 8:44
  • $\begingroup$ Manipulate[ ListLinePlot[{t = Join[data3[[;; -2]], {{data3[[-1, 1]], i}}], lsqcurve[t, 5]}], {i, 0, 100}, Mesh -> All] ...is this what you meant? $\endgroup$ Commented Mar 5, 2016 at 8:47
  • $\begingroup$ also...i do not see the point becoming an outlier....it was previously visible in my code... $\endgroup$ Commented Mar 5, 2016 at 8:54
  • $\begingroup$ Hi @Dr.belisarius....I have changed it to reflect for point 50, Thanks for your help.. $\endgroup$ Commented Mar 6, 2016 at 21:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.