xiaoxin960904的个人博客分享 http://blog.sciencenet.cn/u/xiaoxin960904

博文

MATLAB 多维数组求和、求平均

已有 5606 次阅读 2021-4-14 08:04 |个人分类:Matlab学习笔记|系统分类:科研笔记

用了四五年matlab,遇到问题基本靠搜索引擎,没有看过正经学习的书籍的后果

就是今天我才知道多维数组求和不用写多个sum或者mean,之前还好奇为什么

matlab没有像老古董fortran那样的数组索引方式

example:

test_martrix = rand(4,4,4,4);

test_mean = mean(test_martrix(:)); % 这个等价于 mean(mean(mean(mean(test_martrix))))

test_sum = sum(test_martrix(:)); % 这个等价于 sum(sum(sum(sum(test_martrix))))



https://blog.sciencenet.cn/blog-3386114-1281861.html

上一篇:Matlab 粗箭头绘制
下一篇:Matlab 二维空间滤波
收藏 IP: 222.195.137.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-19 08:05

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部