MATLAB Answers

I want to create normally distributed random variables, and refer to them as my independent variables

48 views (last 30 days)
John Bjerkvig Lea
John Bjerkvig Lea on 28 Feb 2021
Answered: John D'Errico on 28 Feb 2021
I want to start by entering the following command in MATLAB: rng(10, ’twister’). Then, create 100 normally distributed random variables with 100 observations each and refer to those as my independent variables x1, . . . , x100.

Answers (1)

John D'Errico
John D'Errico on 28 Feb 2021
The answer is, DON'T.
Instead, learn to use MATLAB. MATLAB is an array language. A language of vectors and arrays.
X = randn(100,100);
Now you can treat each row (or column) of this array as a vector of length 100.
So instead of having to create variables with different names, you have an entire array of variables. X(:,1) is the first such variable.
And now you can work with ALL of those variables at once.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by