MATLAB Answers

51 uniformly-distributed points

7 views (last 30 days)
Jamie Williamson
Jamie Williamson on 15 Sep 2021
Edited: Dave B on 15 Sep 2021
I have a question asking for 51 uniformly distributed points. How might this be done?
Replaces the continuous domain of xM from 0 to 5 (i.e. 0 ≤ xM ≤ 5) with a set of 51 uniformly-distributed points.

Accepted Answer

Dave B
Dave B on 15 Sep 2021
Edited: Dave B on 15 Sep 2021
You can create uniformly (linearly) distributed values with the linspace function:
x = linspace(0, 5, 51)
x = 1×51
0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000 1.8000 1.9000 2.0000 2.1000 2.2000 2.3000 2.4000 2.5000 2.6000 2.7000 2.8000 2.9000
Alternatively, you might have noticed that the set of points you're looking for are 0.1 increments, and could have used the colon operator to accomplish the same:
x = 0:.1:5
x = 1×51
0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000 1.8000 1.9000 2.0000 2.1000 2.2000 2.3000 2.4000 2.5000 2.6000 2.7000 2.8000 2.9000

More Answers (0)

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by