Generate a total of 1024 random numbers between -1023 and 1024(integers only) with almost zero mean value and standard deviation must be kept around 100.
I could not find how to generate these numbers.. I have searched for all MATLAB functions rand(), randn().. but couldnt combine all the features.. for instance when i arrenge the range of numbers i couldnt adjust the mean and std or vice versa..:(
If you're using uniform, if you specify the range, you get the stddev
- nothing you can do about it. You could specify a stdev but then
you'd get a range that is not [-1024 to +1024]. I suppose you could
throw out numbers outside the range. Same for Gaussian - for a stdev
of 100 you'll not likely get any numbers larger than 400 or less than
-400 or so.
Here is it for Gaussian: (I just adapted the demo straight out of the
help for randn().)
workspace; % Display workspace panel.
% Generate values from a normal distribution with
% mean 0 and standard deviation 100.
r = 100 .* randn(1024,1);
% Throw out any numbers not in the range [-1024, 1024]
% This likely will not happen.
r(r > 1024) = [];
r(r < -1024) = [];
% Display results.
r_Length = length(r)
r_mean = mean(r)
r_std = std(r)
r_max = max(r)
r_min = min(r)
Is this a matlab question?
Why are you positive that randn will not work?
What can you do to ensure that the results are
integers? Must the integers be distinct?
John
% For integers:
randn('state',4151941)
r = round(100 .* randn(1024,1));
-----SNIP
Hope this helps.
Oww thats right thanks a lot!