フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

What did I do wrong ?

3 ビュー (過去 30 日間)
piggy_jes
piggy_jes 2014 年 11 月 17 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
This is my code :
count=0;
for m=1:9
for n=1:10
for p=1:9
for q=1:10
if abs(a(m,n)- b(p,q))<=500;
count=count+1;
else
count=count+0;
end
end
end
end
end
These are matrices "a" and "b" :
a =
1500 1200 1300 1000 1000 1000 1000 1000 1000 0
0 700 800 500 500 500 500 500 500 0
0 0 500 200 200 200 200 200 200 0
0 0 0 300 300 300 300 300 300 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
>> b
b =
1500 1200 1300 1000 1000 1000 1000 1000 1000 0
0 700 800 500 500 500 500 500 500 0
0 0 500 200 200 200 200 200 200 0
0 0 0 300 300 300 300 300 300 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
I want to count the amount of difference between each of the element in matrix a and b which are not exceed 500.
And as you can see, there are only 90x90 = 1800 sample spaces. But the result from my code(number of count) is 6504!
What did I do wrong ?
  2 件のコメント
Torsten
Torsten 2014 年 11 月 17 日
90x90 makes 8100 ...
Best wishes
Torsten.
piggy_jes
piggy_jes 2014 年 11 月 17 日
Oh, thank you! It's my fault! Lol

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by