Cody

Problem 45443. Generate n equally spaced "intervals" between -x and x (★)

Solution 2215733

Submitted on 17 Apr 2020 by Rafael Hernandez-Walls
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
x = 5; n = 4; y_correct = [-5 -2.5 0 2.5 5]; assert(isequal(spaced_intervals(x,n),y_correct))

ans = -5.0000 -2.5000 0 2.5000 5.0000

2   Pass
x = 9; n = 5; assert(std(diff(spaced_intervals(x,n)))<1e-10)

ans = -9.0000 -5.4000 -1.8000 1.8000 5.4000 9.0000