So here is my code so far:

clear all;

M=1000*ones(100,1); %100 agents with 1000$ initially.

T=input('enter a value for T:'); %the number of times that 2 agents are randomly picked and are allowed to interact.

for i=1:1:T %loop from i=1 to i=T.

x=randi([1 100],1); %agent 1 picked at step i.

y=randi([1 100],1); %agent 2 picked at step i.

R=rand; %generates a random number between 0 and 1

if x==y;

y=randi([1 100],1); %in case picking twice the same agent

end

P=M(x);

Q=M(y);

M(x)=R.*(P+Q); %such reassignment of money ensures no dept after transaction.

M(y)=(1-R).*(P+Q);

disp(' ')

end

for j=1:1:size(M);

fprintf('%5.0f\t%5.0f\n',j,M(j));

end

Mf=sum(M,1); % Mf = total amount of money (~=100,000$)

fprintf('Total amount of money:\n%5.0f\t%5.0f\n',Mf);

C=sort(M);

D=C(81:1:100);

disp(' ')

E=sum(D); % E = total amount of money among the 20 richest agents.

fprintf('Amount of money among the 20 richest agents:\n%5.0f\t%5.0f\n',E);

How can i plot the distribution of money after T pickings ?

I'd guess a gaussian dist, what are the command in this case?

where should I place it within the code?