seed that controls the order of a random function in Matlab

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?

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

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 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.