matlab 高级函数 —— circshift、squeeze
circshift:顾名思义,循环移动,循环的意义在于,移出的数据不丢失,而是来到队列的首部位置,也即其实是将原始序列视为一种圆环。
1. 基本用法
默认为右移。
- Y = circshift(A,K)
- Y = circshift(A,K,dim)
circshift(1:10, 3)
8 9 10 1 2 3 4 5 6 7
2. 简单应用
将 1, 2, 3, 4, 5, 6, 7 变为 1, 5, 2, 6, 3, 7, 4,也即形成犬牙交错的形式:
n = 7;
a = zeros(1, n);
for i = 1:n,
a(i) = i;
a = circshift(a, [0, -1]);
end
a
此时要求长度必须为奇数,而不能为偶数,当长度为偶数时:
n = 1
a = 5 0 6 0 7 0 8 0
3. squeeze
移除 singleton 的维度,所谓 singleton dimension,是指 size(A, dim) = 1 的 dim。
>> y = rand(2, 1, 3)
% size(y, 2) == 1
y(:,:,1) =
0.8147
0.9058
y(:,:,2) =
0.1270
0.9134
y(:,:,3) =
0.6324
0.0975
>> z = squeeze(y)
% 2, 1, 3 ⇒ 2, 3
% 1, 2, 3 ⇒ 2, 3
z =
0.8147 0.1270 0.6324
0.9058 0.9134 0.0975
matlab 高级函数 —— circshift、squeeze的更多相关文章
- Matlab高级教程_第四篇:Matlab高级函数_关键词:drawnow,addpoints,animatedline,getpoints
0. MATLAB真实航母基本的工具,其中的函数/工具不计其数,而且有些函数/工具非常的炫酷.在MATLAB第四篇章把平时工作中用到的些许函数进行使用的讲解 主题1.:drawnow 解释:更新图窗并 ...
- matlab 高级函数 —— colfilt/blockproc (图像)矩阵的分块处理
colfilt 执行功能与 blockproc/nlfilter 类似,但效率更高. B = colfilt(A,[m n],block_type,fun),block_type:distinct/s ...
- matlab 高级函数
2*randn(sz):0 均值,方差为 4(variance), standard deviation:标准差为 2: numel():returns the # of elements: nume ...
- Matlab 中 函数circshift()的用法
a = [ ; ; ]; b = [- - -; - - -;- - -]; c = [ ; ; ]; Hist(:,:,) = a; Hist(:,:,) = b; Hist(:,:,) = c; ...
- Matlab高级教程_第四篇:Matlab高级函数_关键词:arrayfun
% 定义一个句柄并用这个句柄求值 h = @sin; h(3) % % 命令窗口返回内容 % h(3) % ans = % 0.1411 %定义一个完整句柄,@参数+表达式的形式,并给句柄传参 h1 ...
- MATLAB图像处理函数汇总(二)
60.imnoise 功能:增加图像的渲染效果. 语法: J = imnoise(I,type) J = imnoise(I,type,parameters) 举例 I = imread('eight ...
- 基于OpenCV的循环行、列移动函数circShift()
///*12 在Matlab中有个circShift()函数,可以实现行.列的循环移动 /// 在返卷积运算中,会用到这个函数.所以,在Opencv中我也定义同样 /// 功能的函数 /// 该函数有 ...
- Matlab高级教程_第二篇:Matlab相见恨晚的模块_02_并行运算-1
1 更高级的算法牵扯到更多重的循环和复杂的计算,尤其是现在人工智能的算法尤其如此.有些历史知识的人能够了解到,人工智能的很多基本算法其实近百年之前就有了,但是当时的计算机技术达不到去实现这些算法的要求 ...
- MyEclipse调用Matlab打包函数
本文部分内容参考了http://www.360doc.com/content/15/1103/16/1180274_510463048.shtml 一.检查Java环境 对于已经装上JAVA环境的计算 ...
随机推荐
- Maven 异常:Project configuration is not up-to-date with pom.xml解决方案
一.异常信息: 导入maven工程后,出现如下错误: Description Resource Path Location TypeProject configuration ...
- 被误解的MVC和被神化的MVVM
MVC 的历史 MVC,全称是 Model View Controller,是模型 (model)-视图 (view)-控制器 (controller) 的缩写.它表示的是一种常见的客户端软件开发框架 ...
- MyEclipse中 使用svn更新jar包 出现 svn cleanup failed–previous operation has not finished; run cleanup if it was interrupted 导致整个svn异常处理
svn cleanup failed–previous operation has not finished; run cleanup if it was interrupted 2014-07-02 ...
- UVA - 1161 Objective: Berlin(最大流+时序模型)
题目大意:有n个城市m条航线.给出每条航线的出发地,目的地,座位数,起飞时间和到达时间(所给形式为HHMM.记得转化),再给出城市A和B.和到达城市B的最晚时间.如今问一天内最多有多少人能从A飞到B, ...
- 解决安装mysql-connector-odbc-5.3.2 错误1918……不能载入安装或转换器库……的BUG
还是在虚拟机Windows Server 2003上安装mysql-connector-odbc-5.3.2,装着装着就报错了,大致是"错误1918--不能载入安装或转换器库--" ...
- vue-cli3使用vue-svg-loader加载svg
vue-svg-loader Documentation - FAQ webpack loader that lets you use SVG files as Vue components Micr ...
- Activity生命周期的回调,你应该知道得很多其它!--Android源代码剖析(下)
转载请标明原文地址:http://blog.csdn.net/yalinfendou/article/details/46910811[yalinfendou的博客] ...
- java I/O库的设计模式
在java语言 I/O库的设计中,使用了两个结构模式,即装饰模式和适配器模式. 在任何一种计算机语言中,输入/输出都是一个很重要的部分.与一般的计算机语言相比,java将输入/输出的功能和使 ...
- [Angular2 Router] Guard: CanLoad
'canLoad' guard can decide whether a lazy load module can be loaded or not. @Injectable() export cla ...
- Linux基本命令(一)
目标 熟练使用 Linux常用的命令 ls clear cd pwd mkdir touch rm cp mv tree chmod find grep 重定向 软连接.硬链接 压缩 shutdown ...