2
$\begingroup$

I have a data point set embedded in a manipulate. dtpts1a={{X,Y},{X,Y},{X,Y},{X,Y},{X,Y},{X,Y},{X,Y}, and so on and so forth, continuing} How do I alter, how do I change the magnitude of each dependent variable (Y)? I would like to multiply each Y value, all at the same time, with some kind of a function under the control of a slider bar. Like this, {{X,0.5Y},{X,0.5Y},{X,0.5Y}}} or possibly, {{X,2Y},{X,2Y}},{X,2Y}}}. Ideas? Suggestions?

$\endgroup$
4
  • $\begingroup$ you could write it as dtpts1a={{X,n*Y},{X,n*Y},{X,n*Y}... and then have slider for n to change it. $\endgroup$
    – Nasser
    Jul 18, 2020 at 21:23
  • $\begingroup$ Yes, that would work. But I'm hoping for something easier. My data set sums to 128 point pairs {{X,Y}} $\endgroup$
    – OKCarl
    Jul 18, 2020 at 23:04
  • 1
    $\begingroup$ You can use Nasser's solution with MapAt[n*#&, dtpts1a, {All,2}] $\endgroup$
    – Hausdorff
    Jul 18, 2020 at 23:32
  • 1
    $\begingroup$ You could use a dot product: dtpts1a.{{1, 0}, {0, .5}} $\endgroup$
    – Carl Woll
    Jul 19, 2020 at 0:21

1 Answer 1

5
$\begingroup$
dtpts1a = Table[RandomInteger[{1,100}],{i,128},{j,2}];

Manipulate[
    MapAt[n*#&, dtpts1a, {All,2}]
,{n,0,1}]

EDIT

By default Manipulate uses steps of 10^-3 * rangeMax for the variable. You can decrease the step size and use SetAccuracy to always show four digits

Manipulate[
    SetAccuracy[MapAt[n*#&, dtpts1a, {All,2}],5]
,{n,0,1,0.0001}] 
$\endgroup$
2
  • $\begingroup$ Mister Hausdorff's solution works. dtpts1c=MapAt[n*# &, dtpts1a,{All, 2}]; One last question. How do I "SetPrecision" for the output? I am wanting four significant figures for each one of my calculated dependent variables. Thanks in advance. OKCarl $\endgroup$
    – OKCarl
    Jul 19, 2020 at 2:32
  • 1
    $\begingroup$ I just edited my answer $\endgroup$
    – Hausdorff
    Jul 19, 2020 at 8:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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