Matlab中的三和

编程入门 行业动态 更新时间:2024-10-13 14:26:58
本文介绍了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 .

www.mathworks/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中的三和

本文发布于:2023-11-29 11:28:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1646268.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:三和   Matlab

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!