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的更多相关文章

  1. Matlab高级教程_第四篇:Matlab高级函数_关键词:drawnow,addpoints,animatedline,getpoints

    0. MATLAB真实航母基本的工具,其中的函数/工具不计其数,而且有些函数/工具非常的炫酷.在MATLAB第四篇章把平时工作中用到的些许函数进行使用的讲解 主题1.:drawnow 解释:更新图窗并 ...

  2. matlab 高级函数 —— colfilt/blockproc (图像)矩阵的分块处理

    colfilt 执行功能与 blockproc/nlfilter 类似,但效率更高. B = colfilt(A,[m n],block_type,fun),block_type:distinct/s ...

  3. matlab 高级函数

    2*randn(sz):0 均值,方差为 4(variance), standard deviation:标准差为 2: numel():returns the # of elements: nume ...

  4. Matlab 中 函数circshift()的用法

    a = [ ; ; ]; b = [- - -; - - -;- - -]; c = [ ; ; ]; Hist(:,:,) = a; Hist(:,:,) = b; Hist(:,:,) = c; ...

  5. Matlab高级教程_第四篇:Matlab高级函数_关键词:arrayfun

    % 定义一个句柄并用这个句柄求值 h = @sin; h(3) % % 命令窗口返回内容 % h(3) % ans = % 0.1411 %定义一个完整句柄,@参数+表达式的形式,并给句柄传参 h1 ...

  6. MATLAB图像处理函数汇总(二)

    60.imnoise 功能:增加图像的渲染效果. 语法: J = imnoise(I,type) J = imnoise(I,type,parameters) 举例 I = imread('eight ...

  7. 基于OpenCV的循环行、列移动函数circShift()

    ///*12 在Matlab中有个circShift()函数,可以实现行.列的循环移动 /// 在返卷积运算中,会用到这个函数.所以,在Opencv中我也定义同样 /// 功能的函数 /// 该函数有 ...

  8. Matlab高级教程_第二篇:Matlab相见恨晚的模块_02_并行运算-1

    1 更高级的算法牵扯到更多重的循环和复杂的计算,尤其是现在人工智能的算法尤其如此.有些历史知识的人能够了解到,人工智能的很多基本算法其实近百年之前就有了,但是当时的计算机技术达不到去实现这些算法的要求 ...

  9. MyEclipse调用Matlab打包函数

    本文部分内容参考了http://www.360doc.com/content/15/1103/16/1180274_510463048.shtml 一.检查Java环境 对于已经装上JAVA环境的计算 ...

随机推荐

  1. TabControl控件重绘

    原文地址:http://www.codeproject.com/Articles/91387/Painting-Your-Own-Tabs-Second-Edition 在网上看到重绘TabContr ...

  2. 安装filezilla client报错libgnutls版本旧

    http://blog.csdn.net/mofabang/article/details/9212217

  3. C# 获取文件路径,读取项目中某程序集下文件

    获取文件路径 ------------------------------------------------------------------------- winform获取文件路径: stri ...

  4. flask的使用(一)

    1.程序基本的说明 #-*-encoding=utf--*- 从flask中引入类 from flask import Flask ,render_template import config 初始化 ...

  5. CSS两列布局——左侧宽度固定,右侧宽度自适应的3种方法

    1.左侧绝对定位法 直接看代码: <!DOCTYPE html> <html lang="en"> <head> <meta charse ...

  6. Virtualizing physical memory in a virtual machine system

    A processor including a virtualization system of the processor with a memory virtualization support ...

  7. Spring配置文件头及xsd文件版本

    最初Spring配置文件的头部声明如下: Xml代码   <?xml version="1.0" encoding="UTF-8"?> <!D ...

  8. HDU 1496 Equations hash HDU上排名第一!

    看题传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1496 题目大意: 给定a,b,c,d.a*x1^2+b*x2^2+c*x3^2+d*x4^2=0 ...

  9. 14、USB摄像头(V4L2接口)的图片采集

    参考网站http://www.cnblogs.com/surpassal/archive/2012/12/19/zed_webcam_lab1.html 一.一些知识 1.V4L和V4L2. V4L是 ...

  10. css实现悬浮效果的阴影

    要实现的效果图: 图片.png 实现的代码: -webkit-box-shadow:0px 3px 3px #c8c8c8 ; -moz-box-shadow:0px 3px 3px #c8c8c8 ...