This is a basic MATLAB operation. It is for instructional purposes.
---
If you want to get a random permutation of integers randperm will help.
Given n, put the integers [1 2 3... N] in a random order.
Yes, the test suite is not conclusive, but it is pretty close!
Surely these ! echo "function assert(~) " >./assert.m solutions are not valid?
This solution seems to run correctly in MATLAB (desktop)... can anyone tell me why it is coming back with an "Assertion Failed"?
function vec = makeRandomOrdering(n)
vec = zeros(1, numel(n));
flags = zeros(1, numel(n));
index = 1;
while (sum(flags) ~= numel(n))
pos = randi(numel(n));
if (flags(pos) ~= 1)
vec(index) = n(pos);
index = index + 1;
flags(pos) = 1;
end
end
end
The Hitchhiker's Guide to MATLAB
2694 Solvers
232 Solvers
Generate a random matrix A of (1,-1)
161 Solvers
Area of an equilateral triangle
1703 Solvers
Tick. Tock. Tick. Tock. Tick. Tock. Tick. Tock. Tick. Tock.
615 Solvers