generate a set data with random errors

we can generate a set of data with a random error about some mean value with the command
>>num=100;
>>spr=0.1;
>>data=5.0=spr*sign(1.0-2.0*rand(1,num)).*rand(1,num);
a)what is the last line doing?
b)write a program which computes the mean and standard deviation of the data.
plz help me.!!!!!!

2 件のコメント

Andrei Bobrov
Andrei Bobrov 2012 年 3 月 5 日
as?
data=5.0 + spr*sign(1.0-2.0*rand(1,num)).*rand(1,num);
Walter Roberson
Walter Roberson 2012 年 3 月 5 日
http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer

サインインしてコメントする。

回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2012 年 3 月 5 日

0 投票

er1 - random error - uniform distribution from -0.1 to 0.1
spr = .1;
er1 = spr*sign(1.0-2.0*rand(1,num)).*rand(1,num);
OR
er1 = spr*(2*rand(1,num) - 1)

2 件のコメント

henny
henny 2012 年 3 月 5 日
i am unable to understand
Andrei Bobrov
Andrei Bobrov 2012 年 3 月 5 日
please read about 'rand': http://www.mathworks.com/help/techdoc/ref/rand.html

サインインしてコメントする。

タグ

質問済み:

2012 年 3 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by