フィルターのクリア

standard deviation in matlab

2 ビュー (過去 30 日間)
john
john 2011 年 3 月 9 日
Hello, I have calculate in my program the mean value and I am trying to calculate the standard deviaton value of an array 20x20, without using the std command.Next, I compare my result to that whoch I get when I use the std command, but they are different.Could someone explain me the reason? Is their any problem in the types of my algorithm? Here is my code:
mean_value = 65.4250;
sum_dev = 0;
for i=1:1:20
for j=1:1:20
sum_dev = sum_dev + ((ROI(i,j)- mean_value)^2);
end;
end;
std_dev = ((sum_dev/(40-1))^(1/2));
disp(std_dev);
129.0786
std(ROI(:), 0,1)
ans =
40.3552
  1 件のコメント
Jan
Jan 2011 年 3 月 9 日
Sorry for asking: Is the "mean_value" the mean of the values?!

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

採用された回答

Teja Muppirala
Teja Muppirala 2011 年 3 月 9 日
You probably meant to write (400-1) and not (40-1).
  2 件のコメント
john
john 2011 年 3 月 9 日
thanks a lot
Teja Muppirala
Teja Muppirala 2011 年 3 月 9 日
It should be noted, you could have avoided this by writing something like:
std_dev = ((sum_dev/(numel(ROI)-1))^(1/2));
instead. In general, you're probably better off not hardcoding numbers like "400" (same goes for the loop indices). This is a lot more flexible since it works for any ROI size.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by