Random Indexing from an array for different values

조회 수: 13 (최근 30일)
Harrison Chong
Harrison Chong 2019년 1월 14일
댓글: Guillaume 2019년 1월 14일
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
Harrison Chong
Harrison Chong 2019년 1월 14일
I am trying to code the formula attached, where three points i j and k are chosen randomly from a 2-d figure, and I need to choose every possible unique combination of three points on the figure to implement the formula.
Guillaume
Guillaume 2019년 1월 14일
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by