Random Indexing from an array for different values
3 views (last 30 days)
Show older comments
Hi all, I want to index a random value from an array named "x" to fill the value of something called a1 and then make sure that my code indexes from the same position randomly selected for x, but from an array named "y" to fill the value of something called b1. I then want to do this process for a2 and b2, and then a3 and b3. I then have associated m1, m2, m3 that are associated with the same spots in each array that were chosen previously. I'm not sure how to do this and have attached my best guess. Hints would be very helpful! I have no clue how to ensure a1 and b1 are indexed from the same positions in the respective arrays. I have attached the arrays themselves.
global h;
global x;
global y;
a1 = randperm(length(global_x),1;
b1 = randperm(length(global_y),1;
a2 = randperm(length(global_x),1;
b2 = randperm(length(global_y),1;
a3 = randperm(length(global_x),1;
b3 = randperm(length(global_y),1;
m_1 = randperm(length(global_h),1;
m_2 = randperm(length(global_h),1;
m_3 = randperm(length(global_h),1;
if a1 == a2
then a2 = randperm(length(global_x)
end
if a1 == a3
then a3 = randperm(length(global_x)
end
if a2 == a3
then a2 = randperm(length(global_x)
end
if b1 == b2
then b2 = randperm(length(global_y);
end
if b1 == b3
then b3 = randperm(length(global_y);
end
if b2 == b3
then b2 = randperm(length(global_y);
end
if m1 == m2
then m2 = randperm(length(global_h)
end
if m1 == m3
then m3 = randperm(length(global_h)
end
if m2 == m3
then m2 = randperm(length(global_h)
end
4 Comments
Guillaume
on 14 Jan 2019
I don't think there's enough contest for us to understand the formula but in any case "every possible unique combination of three points on the figure" may take you a while considering that there's an infinity of points inside a figure.
Answers (0)
See Also
Categories
Find more on Matrix Indexing 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!