一分钟了解“matlab用矩阵写法代替for循环”
来源:互联网 发布:知乎 室内环保 编辑:程序博客网 时间:2024/05/21 08:59
K>> [xx,yy]=meshgrid(-3:3,-3:3);
K>> f=@(x,y) x^2+y^2;
K>> arrayfun(f,xx,yy)
ans =
18 13 10 9 10 13 18
13 8 5 4 5 8 13
10 5 2 1 2 5 10
9 4 1 0 1 4 9
10 5 2 1 2 5 10
13 8 5 4 5 8 13
K>> f=@(x,y) x^2+y^2;
K>> arrayfun(f,xx,yy)
ans =
18 13 10 9 10 13 18
13 8 5 4 5 8 13
10 5 2 1 2 5 10
9 4 1 0 1 4 9
10 5 2 1 2 5 10
13 8 5 4 5 8 13
18 13 10 9 10 13 18
matlab执行多重for循环的速度是很慢的,了解这一招可以极大提高处理速度。
阅读全文
0 0
- 一分钟了解“matlab用矩阵写法代替for循环”
- matlab 矩阵代替for循环
- 一分钟了解"matlab用meshgrid实现for循环的遍历功能"
- 一分钟了解“Matlab矩阵 [~,a,b,c]的~是什么意思”
- 一分钟了解“Matlab把矩阵中的负数变成零”
- 一分钟了解“matlab把矩阵串联的cat函数”
- 一分钟了解“matlab把一个矩阵矩阵范围拉伸到minVal~maxVal的范围内”
- Matlab:用内建函数代替for循环
- 一分钟了解“Matlab直接求矩阵所有元素的平均值mean2”
- 一分钟了解“Matlab直接求矩阵所有元素的标准差std2”
- 一分钟了解“Matlab求两个矩阵的相关程度corr2”
- 一分钟了解“Matlab提取出矩阵中大于某值的元素”
- 一分钟了解“Matlab把矩阵边缘上的像素设置为特定值”
- 一分钟了解“Matlab中求散度函数divergence”
- 一分钟了解“Matlab绘图三维数据”
- 一分钟了解“Matlab实现tophat变换”
- 一分钟了解“Matlab的squeeze函数”
- 一分钟了解"matlab进行特征值分解"
- 第5章 神经网络
- 初学如何选择thread数量
- 一分钟了解“matlab中访问当前路径和上一个路径”
- 27.多媒体(音乐播放器)
- idea 使用java 链接sqlservice 2008
- 一分钟了解“matlab用矩阵写法代替for循环”
- nginx服务
- 设计模式-3-原型模式
- python写入文件到mongoDB
- POJ 3107 Godfather 笔记
- 欢迎使用CSDN-markdown编辑器
- Cuda的问题
- 【备战秋招Day 3】经典面试题9-12及在线编程题7-9答案
- J2EE安装问题及汉化