Kourkoumpini
Kourkoumpini

Reputation: 3

Randperm columns of a matrix

Hey i have a matrix A 3x3..

A= [1 2 3 4
    2 3 4 5
    3 4 5 6]

I want with randperm to generate a new matrix B where the columns will be shuflled..Anyone can help?

Upvotes: 0

Views: 2358

Answers (1)

blue note
blue note

Reputation: 29081

You can use randperm like this:

B = A(:, randperm(size(A,2)))

Upvotes: 3

Related Questions