1
$\begingroup$

I do have a global variable called w1, which is used as a factor in a dataset, however I want to make this factor dynamic.

w1 = 0.2;

w2 = 0.2;

w3 = 0.2;

w4 = 0.2;

w5 = 0.2;

column1 = w1*RandomInteger[{1, 5}, 100];

column2 = w2*RandomInteger[{1, 5}, 100];

column3 = w3*RandomInteger[{1, 5}, 100];

column4 = w4*RandomInteger[{1, 5}, 100];

column5 = w5*RandomInteger[{1, 5}, 100];

column6 = RandomInteger[{0, 1}, 100];

(Creating a matrix consisting of those 6 columns, named dummydata)

dummydata = {column1, column2, column3, column4, column5, column6};

So the variable I am talking about would be, f.e. w1. Any help would be much appreciated! The goal would be to create a dataset that displays those values dynamically

$\endgroup$
2
$\begingroup$

Like this?

w2 = 0.2;
w3 = 0.2;
w4 = 0.2;
w5 = 0.2;
n = 10;
A = N[Join[RandomInteger[{1, 5}, {n, 5}], RandomInteger[{0, 1}, {n, 1}], 2]];
Block[{w},
  dummydata = w \[Function] Evaluate[A.DiagonalMatrix[{w, w2, w3, w4, w5, 1.}]]
];
Manipulate[
 MatrixForm[dummydata[w]],
 {w, 0, 1}
 ]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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