Random order of rows Matlab

To shuffle the rows of a matrix, you can use RANDPERM shuffledArray = orderedArray(randperm(size(orderedArray,1)),:); randperm will generate a list of N random values and sort them, returning the second output of sort as result.

How to normalize a vector in MATLAB efficiently? Any related built-in function? [closed]

The original code you suggest is the best way. Matlab is extremely good at vectorized operations such as this, at least for large vectors. The built-in norm function is very fast. Here are some timing results: V = rand(10000000,1); % Run once tic; V1=V/norm(V); toc % result: 0.228273s tic; V2=V/sqrt(sum(V.*V)); toc % result: 0.325161s tic; … Read more

How do I visualize a matrix with colors and values displayed?

You can create this sort of plot yourself pretty easily using the built-in functions imagesc and text and adjusting a number of parameters for the graphics objects. Here’s an example: mat = rand(5); % A 5-by-5 matrix of random values from 0 to 1 imagesc(mat); % Create a colored plot of the matrix values colormap(flipud(gray)); … Read more