フィルターのクリア

Calculation of a double sum

2 ビュー (過去 30 日間)
xenon99942
xenon99942 2018 年 7 月 19 日
回答済み: Dimitris Kalogiros 2018 年 7 月 19 日
Hey all!
i want to calculate the double sum over w_ij * v_((2+k*3)+i,(2+l*3)+j). The indices for i should run from -1 to 1 (so -1,0,1), same for j. The indices for k are from 0:893 and for l from 0:356. And w should be -8 if i=j=0, otherwhise it is w=1. i Tried:
for i = -1:1
for j = -1:1
if i == 0 & j==0
w = -8
else
w = 1
end
for k = 0:893
for l = 0:356
sum(w*v((2+k*3)+i,(2+l*3))+j)
end
end
end
end
% code
end
But the results were not as expected. Can you help me? Thanks!

採用された回答

Dimitris Kalogiros
Dimitris Kalogiros 2018 年 7 月 19 日
mySum=0;
for i = -1:1
for j = -1:1
if i == 0 & j==0
w = -8;
else
w = 1;
end
for k = 0:893
for l = 0:356
mySum=mySum+( w*v((2+k*3)+i,(2+l*3))+j );
end
end
end
end
disp(['mySum = ' num2str(mySum)]);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by