How can I make 1 by length x array of random numbers from -pi to pi ??
1 view (last 30 days)
Show older comments
How can I make 1 by length x array of random numbers from -pi to pi ??
0 Comments
Accepted Answer
Jan
on 1 Nov 2021
See:
help rand
% Generate values from the uniform distribution on the interval (a, b):
r = a + (b - a) .* rand(x, 1);
Now set a=-pi and b=p:
r = -pi + 2*pi * rand(x, 1);
Actually we do not solve homework questions in the forum. But here I hope you see, how useful the hint is to take a look into the documentation. For questions concerning a command, start with help() and doc(). If this does not help directly, look at the bottom in the "See also" line, which contains other similar commands.
0 Comments
More Answers (1)
M.MUSBA Elhadid
on 31 Oct 2021
Edited: M.MUSBA Elhadid
on 31 Oct 2021
x = ones(1,100); a = [rand(1,length(x))-0.5]+linspace(-pi+0.5,pi-0.5,length(x));
2 Comments
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!