Matlab中的三和 [英] triple sum in matlab
本文介绍了Matlab中的三和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要计算以下总和:
我尝试使用以下代码:
I = imread('C:\Users\Billal\Desktop\image.png');
[x,y,z]=size(I);
x=(1:x) ;
y=(1:y) ;
z=(1:z) ;
Fx=ones(size(x));
Fy=ones(size(y));
Fz=ones(size(z));
X=x*Fy';
Y=Fx*y';
Z=z*Fz';
f=I(X,Y,Z);
sum1 = sum(f(:));
[x1,y1,z1]=size(I);
total = sum1/(x1*y1*z1);
但是结果是0.我不知道问题出在哪里?我正在关注本教程.
But the result is 0 . I could not figure out where is the problem ? I am following this tutorial .
https://www.mathworks.com/matlabcentral/newsreader/view_thread/126366
请帮助我解决这个问题.
Please help me to solve this question .
推荐答案
您可以一步完成此操作:
You can do this in a single step:
result=1/prod(size(I))* sum(I(:));
最后,方程式只是将整个图像的值相加.
In the end, the equation just adds up values of the whole image.
您链接到的问题需要对y
的值求和.不需要,您只需要对索引求和,因此不需要所有这些Fx,Fy
内容
The question you link to needs to sum over values of x
and y
. You don't, you just need to sum over indexes, thus there is no need of all those Fx,Fy
things
这篇关于Matlab中的三和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文