It's supposed to use an rng to simulate a dice game, so after it's run through the permutations I have a series of if statements that increment variables by one depending upon the result.
%clearing any old data
clc;
clear all;
finaltotal=0;
tot2=0;
tot3=0;
tot4=0;
tot5=0;
tot6=0;
tot7=0;
tot8=0;
tot9=0;
tot10=0;
tot11=0;
tot12=0;
%the loop
for i=1:1000
%calculating a role of five dice
a=rng;
b1=rand(1,1);
c1=ceil(b1*6);
b2=rand(1,1);
c2=ceil(b2*6);
b3=rand(1,1);
c3=ceil(b3*6);
b4=rand(1,1);
c4=ceil(b4*6);
b5=rand(1,1);
c5=ceil(b5*6);
total1=c1+c2+c3+c4+c5;
%determing if the player will accept that role
if (total1>24)
finaltotal=total1-15;
elseif (c1==6 || c2==6 || c3==6 || c4==6 || c5==6)
a=rng;
b1=rand(1,1);
c1=ceil(b1*6);
b2=rand(1,1);
c2=ceil(b2*6);
b3=rand(1,1);
c3=ceil(b3*6);
b4=rand(1,1);
c4=ceil(b4*6);
total2=c1+c2+c3+c4;
%Computing if this role is acceptable
if (total2>17)
finaltotal=total2-9;
elseif (c1==5 || c2==5 || c3==5 || c4==5 || c5==5)
a=rng;
b1=rand(1,1);
c1=ceil(b1*6);
b2=rand(1,1);
c2=ceil(b2*6);
b3=rand(1,1);
c3=ceil(b3*6);
total3=c1+c2+c3;
%The player can take another chance
if (total3>12)
finaltotal=total3-4;
%And the players' last chance.
elseif (c1==4 || c2==4 || c3==4 || c4==4 || c5==4)
a=rng;
b1=rand(1,1);
c1=ceil(b1*6);
b2=rand(1,1);
c2=ceil(b2*6);
total4=c1+c2;
finaltotal=total4;
end;
end;
end;
%Adding up all the times each total is earned
if (finaltotal==2)
tot2=tot2+1;
end;
if (finaltotal==3)
tot3=tot3+1;
end;
if (finaltotal==4)
tot4=tot4+1;
end;
if (finaltotal==5)
tot5=tot5+1;
end;
if (finaltotal==6)
tot6=tot6+1;
end;
if (finaltotal==7)
tot7=tot7+1;
end;
if (finaltotal==8)
tot8=tot8+1;
end;
if (finaltotal==9)
tot9=tot9+1;
end;
if (finaltotal==10)
tot10=tot10+1;
end;
if (finaltotal==11)
tot11=tot11+1;
end;
if (finaltotal==12)
tot12=tot12+1;
end;
end;
%Compiling the data into one vector
fdat=dataset(tot2,tot3,tot4,tot5,tot6,tot7,tot8,tot9,tot10,tot11,tot12);
disp(fdat);
slice=fdat(2,:);
disp(slice);
At the end the bit about compiling works, but the slice bits do not. The only problem with fdat is that it also contains the variable names, so I can't graph it.
EDIT: I'm an idiot. If this ever happens to you just make a vector with each variable in one position, and then plot that.