sum up Loop of random numbers

1 Ansicht (letzte 30 Tage)
Lucas Kellermann
Lucas Kellermann am 31 Jan. 2022
The size of X1, X2, Y1,Y2 are 200x200 with different values.
I have the following code (the code is shortened and simplified so please don't ask why I do it this way):
for r = 1:100
% get random numbers for array X1
a_x = (5*rand(size(X1))-2.5);
a_y = (8*rand(size(Y1))-2.5);
l_x = (5*rand(size(X1))-2.5);
l_y = (8*rand(size(Y1))-2.5);
% get random numbers for array X2
a_x2 = (5*rand(size(X1))-2.5);
a_y2 = (8*rand(size(Y1))-2.5);
l_x2 = (5*rand(size(X1))-2.5);
l_y2 = (8*rand(size(Y1))-2.5);
% Add random numbers to the values in X1 and X2
X1_MC = X1+(a_x+l_x);
Y1_MC = Y1+(a_y+l_y);
X2_MC = X2+(a_x2+l_x2);
Y2_MC = Y2+(a_y2+l_y2);
% Subtract cell X1_MC(100,175) from cell X2_MC(100,25)
Q(r) = X1_MC(100,175)
X(r) = X2_MC(100,25)
QX(r) = Q(r) - X(r)
end
I can not get the values in a (a_x a_y a_x2 a_y2) and l (l_x l_y l_x2 l_y2) to recalculate for each iteration. They stay the same at the end, so i get alway the same values in QX.
  3 Kommentare
Lucas Kellermann
Lucas Kellermann am 31 Jan. 2022
Sorry I mean all a and l
Benjamin Thompson
Benjamin Thompson am 31 Jan. 2022
Can you post a full script demonstrating the problem, that includes your definition of X1 and Y1?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by