Function to create matrix with different starting elements per row
Show older comments
I created the following matrix: A with random numbers 1-8, each element with 4 repetitions, A has 6rows, 32columns. I know there are more elegant ways to do this, but I am a matlab beginner, therefore I used the knowledge I have...
A1 = [1:8,1:8,1:8,1:8];
A1 = A1(randperm(length(A1)));
A2 = [1:8,1:8,1:8,1:8];
A2 = A2(randperm(length(A2)));
A3 = [1:8,1:8,1:8,1:8];
A3 = A3(randperm(length(A3)));
A4 = [1:8,1:8,1:8,1:8];
A4 = A4(randperm(length(A4)));
A5 = [1:8,1:8,1:8,1:8];
A5 = A5(randperm(length(A5)));
A6 = [1:8,1:8,1:8,1:8];
A6 = A6(randperm(length(A6)));
Aall(1,:)=A1;
Aall(2,:)=A2;
Aall(3,:)=A3;
Aall(4,:)=A4;
Aall(5,:)=A5;
Aall(6,:)=A6;
Now I want to make sure that the first element of each row is unequal to the previous one, using a function. I struggle with creating this function...any help is appreciated!
Answers (0)
Categories
Find more on MATLAB 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!