- x = -1 + randn(200) simply shifts mean of RNV from 0 to -1 leaving range alone about mean
- plot (x,'bd') plots the two columns against ordinal number 1:200 since is no 'x' argument supplied, only 'y'. Just naming a variable 'x' doesn't change meaning of positional arguments.
How to generate 200 random numbers between -1 and 1 (x-axis and y-axis), resulting in plot from x-axis -1 to 1 and y-axis -1 tot 1 filled with 200 blue diamond points?
6 views (last 30 days)
Show older comments
I can't get the first generated random number to be drawn at x= -1. it always starts a 1 and has an interval of 1 until 200. I do not want that.
I want to create a vector x (containing 200 random values between -1 and 1).
x = -1 + randn(200)
subplot(1,2,1), plot (x,'bd')
axis([-1 1 -1 1]);
0 Comments
Accepted Answer
dpb
on 25 Mar 2018
Edited: dpb
on 25 Mar 2018
Two problems--
Try
x=2*rand(200,1)-1;
y=2*rand(200,1)-1;
plot(x,y,'bd')
for uniform PRVs; note that randn generates PR Normal Vs
More Answers (0)
See Also
Categories
Find more on Data Distribution Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!