Incompatible indices after trying to add multiple output rand functions.
Show older comments
%% I wrote this code as a monte carlo simulation in order to sum the randomly generated weights of 15 boxes.
%% Each box is the sum of X and Y, made in a way where all the boxes are different (using rand commands).
%% My error is when I try to add X and Y, it says i cannot because the indices of the sides are not compatible.
%% How do I make them compatible?
N = 1000 ;
Box = zeros(N,1);
Relativefreq=zeros(N,1);
count=0 ;
for i=1:1000;
X=sum(1.2+0.18*randn(260,15));
Y=sum(1.1+(1.5-1.1)*rand(140,15));
Box(i)=(X+Y); %it says the indices the left and right of this are not comptible.
if Box(i)>=7430
count = count + 1 ;
end
Relativefreq(i) = count/i ;
end
Accepted Answer
More Answers (0)
Categories
Find more on Random Number Generation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!