Cody

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

Solution 3144621

Submitted on 10 Oct 2020 by Jay Hall
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))

y = -5.0000 -2.5000 0 2.5000 5.0000

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

y = -9.0000 -5.4000 -1.8000 1.8000 5.4000 9.0000

Suggested Problems

More from this Author46

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!