# seed that controls the order of a random function in Matlab I used Matlab kmeans function to do clustering for two datasets: data1 and data2. I have three main files, containing the following codes respectively,

I used Matlab kmeans function to do clustering for two datasets: data1 and data2. I have three main files, containing the following codes respectively,

```result1 = kmeans(data1, 4);
result2 = kmeans(data2, 4);

r1 = kmeans(data1,4);
r2 = kmeans(data2,4);
```

I noticed that result1 and r1 are the same, but result2 and r2 are slightly different. I believe that this is caused by the randomness in the kmeans algorithm. In the 1st and 2nd files, data1 is executed first and thus kmeans uses the same "seed". In the 1st and 3rd files, data2 is executed at different stages. The kmeans used for result1 has an effect on the following kmeans.

My question is: can we set up seed in certain way so that r2 and result2 are the same?

## Learn MATLAB Programming for Engineers | MATLAB Training

Learn to use MATLAB for problem solving, run scripts, write code and do data analysis and visualization, solve equations, do math operations and manipulate matrices, and formulate your own logic and convert complex problems into MATLAB code and solve them using programming skills.

## MATLAB vs Python: Why and How to Make the Switch

Learn about MATLAB vs Python, why and how you should switch from MATLAB to Python. Evaluate the differences of using MATLAB vs Python. Convert scripts from MATLAB to Python. MATLAB® is widely known as a high-quality environment for any work that involves arrays, matrices, or linear algebra.

## MATLAB Numpy element wise multiplication issue

Please see the MATLAB code and equivalent Numpy code below. Question: How can I get the D variable same in Numpy as MATLAB's?

## Learn Machine Learning Classification Algorithms using MATLAB

Classification is a very interesting area of machine learning (ML). Learn the basics of MATLAB and understand how to use different machine learning algorithms using MATLAB, with emphasis on the MATLAB toolbox called statistic and machine learning toolbox. Learn the common classification algorithms.

## Figure Properties in MATLAB

In this quick tutorial, we are going to walk through two basic functions, get() and set(), that can be used to manipulate the properties…