Unique factorial design or number sequence
Afficher commentaires plus anciens
Hi,
How would I be able to generate a unique sequence by combining [4 6 8 10 12] and [1 2 3], like the ones below:
4 4 4 4 4 1
4 4 4 4 4 2
4 4 4 4 4 3
4 4 4 4 6 1
4 4 4 4 6 2
4 4 4 4 6 3
. . .. . . . .
12 12 12 12 12 1
12 12 12 12 12 2
12 12 12 12 12 3
However, I do not need repetitions, e.g., I need only one sequence 6 8 8 8 8 1 and NOT 8 6 8 8 8 1
Réponse acceptée
Plus de réponses (2)
Image Analyst
le 24 Nov 2017
Here's one way:
v1 = [4 6 8 10 12]
v2 = [1 2 3]
n1 = length(v1)
n2 = length(v2)
row = 1;
output = zeros(n1^5*n2, n1+1);
for k1 = 1 : n1
for k2 = 1 : n1
for k3 = 1 : n1
for k4 = 1 : n1
for k5 = 1 : n1
for k6 = 1 : n2
vec = [v1(k1), v1(k2), v1(k3), v1(k4), v1(k5), v2(k6)];
output(row, :) = vec;
row = row + 1;
end
end
end
end
end
end
% Print to command window:
output
mounika
le 24 Nov 2017
You can start with this:
a = [4 6 8 10 12];
b= [1 2 3];
c = ones(1,6); % initialize to ones
t = randi([1,5],1,1); % to randomly pick a number from 'a'
z = randi([1,3],1,1); % to randomly pick a number from 'a'
c = c.*a(t);
c(:,end) = b(z); % assign the end value with any no of b
disp(c);
This gives numbers like: 10 10 10 10 10 2 8 8 8 8 8 3 2 2 2 2 2 1 ...
I didn't really understand the last part of your question ' However, I do not need repetitions, e.g., I need only one sequence 6 8 8 8 8 1 and NOT 8 6 8 8 8 1'
You can change the above code for your specifications.
Catégories
En savoir plus sur Design of Experiments (DOE) dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!