学习matlab总结(定稿)

时间:2019-05-12 12:57:11下载本文作者:会员上传
简介:写写帮文库小编为你整理了多篇相关的《学习matlab总结(定稿)》,但愿对你工作学习有帮助,当然你在写写帮文库还可以找到更多《学习matlab总结(定稿)》。

第一篇:学习matlab总结(定稿)

绘图函数 bar 竖直条图 barh 水平条图 hist 直方图

histc 直方图计数 hold 保持当前图形 loglog x,y对数坐标图 pie 饼状图 plot 绘二维图 polar 极坐标图

semilogy y轴对数坐标图 semilogx x轴对数坐标 subplot 绘制子图 bar3 数值3D竖条图 bar3h 水平3D条形图 comet3 3D慧星图 cylinder 圆柱体

fill3 填充的3D多边形 plot3 3维空间绘图

quiver3 3D震动(速度)图 slice 体积薄片图 sphere 球

stem3 绘制离散表面数据 waterfall 绘制瀑布 trisurf 三角表面

clabel 增加轮廓标签到等高线图中datetick 数据格式标记 grid 加网格线

gtext 用鼠标将文本放在2D图中 legend 图注

plotyy 左右边都绘Y轴 title 标题

xlabel X轴标签 ylabel Y轴标签 zlabel Z轴标签 contour 等高线图 contourc 等高线计算 contourf 填充的等高线图 hidden 网格线消影

meshc 连接网格/等高线

mesh 具有参考轴的3D网格 peaks 具有两个变量的采样函数 surf 3D阴影表面图

surface 建立表面低层对象 surfc 海浪和等高线的结合 surfl 具有光照的3D阴影表面 trimesh 三角网格图

多项式与插值

conv 卷积和多项式乘法 roots 多项式的根

poly 具有设定根的多项式 polyder 多项式微分 polyeig 多项式的特征根 polyfit 多项式拟合

polyint 解析多项式积分 polyval 多项式求值

polyvalm 矩阵变量多项式求值 residue 部分分式展开 interp1 一维插值 interp2 二维插值 interp3 三维插值

interpft 使用FFT的一维插值 interpn 多维插值

meshgrid 为3维点生成x和y的网格 ndgrid 生成多维函数和插值的数组 pchip 分段3次Hermite插值多项式 ppval 分段多项式的值 spline 3次样条数据插值

3、基本矩阵和矩阵操作

blkding 从输入参量建立块对角矩阵 eye 单位矩阵

linespace 产生线性间隔的向量 logspace 产生对数间隔的向量 numel 元素个数

ones 产生全为1的数组 rand 均匀颁随机数和数组 randn 正态分布随机数和数组

zeros 建立一个全0矩阵 colon)等间隔向量

cat 连接数组

diag 对角矩阵和矩阵对角线 fliplr 从左自右翻转矩阵 flipud 从上到下翻转矩阵 repmat 复制一个数组 reshape 改造矩阵 roy90 矩阵翻转90度 tril 矩阵的下三角

triu 矩阵的上三角 dot 向量点集 cross 向量叉集

ismember 检测一个集合的元素 intersect 向量的交集 setxor 向量异或集 setdiff 向是的差集 union 向量的并集

数值分析和傅立叶变换 cumprod 累积 cumsum 累加

cumtrapz 累计梯形法计算数值微分 factor 质因子

inpolygon 删除多边形区域内的点 max 最大值

mean 数组的均值 mediam 中值 min 最小值

perms 所有可能的转换 polyarea 多边形区域 primes 生成质数列表 prod 数组元素的乘积 rectint 矩形交集区域 sort 按升序排列矩阵元素 sortrows 按升序排列行 std 标准偏差 sum 求和

trapz 梯形数值积分 var 方差

del2 离散拉普拉斯 diff 差值和微分估计 gradient 数值梯度 cov 协方差矩阵 corrcoef 相关系数 conv2 二维卷积

conv 卷积和多项式乘法 filter IIR或FIR滤波器

deconv 反卷积和多项式除法 filter2 二维数字滤波器

cplxpair 将复数值分类为共轭对 fft 一维的快速傅立叶变换 fft2 二维快速傅立叶变换

fftshift 将FFT的DC分量移到频谱中心ifft 一维快速反傅立叶变换 ifft2 二维傅立叶反变换 ifftn 多维快速傅立叶变换 ifftshift 反FFT偏移

nextpow2 最靠近的2的幂次 unwrap 校正相位角

2、基本数学函数

abs 绝对值和复数模长

acos,acodh 反余弦,反双曲余弦 acot,acoth 反余切,反双曲余切 acsc,acsch 反余割,反双曲余割 angle 相角

asec,asech 反正割,反双曲正割 secant 正切

asin,asinh 反正弦,反双曲正弦 atan,atanh 反正切,双曲正切 tangent 正切

atan2 四象限反正切 ceil 向着无穷大舍入 complex 建立一个复数 conj 复数配对

cos,cosh 余弦,双曲余弦 csc,csch 余切,双曲余切 cot,coth 余切,双曲余切 exp 指数

fix 朝0方向取整 floor 朝负无穷取整 gcd 最大公因数 imag 复数值的虚部 lcm 最小公倍数 log 自然对数

log2 以2为底的对数 log10 常用对数 mod 有符号的求余

nchoosek 二项式系数和全部组合数real 复数的实部 rem 相除后求余

round 取整为最近的整数 sec,sech 正割,双曲正割 sign 符号数

sin,sinh 正弦,双曲正弦 sqrt平方根

tan,tanh 正切,双曲正切

1、特殊变量与常数 ans 计算结果的变量名

computer 确定运行的计算机 eps 浮点相对精度 Inf 无穷大 I 虚数单位

inputname 输入参数名 NaN 非数

nargin 输入参数个数 nargout 输出参数的数目 pi 圆周率

nargoutchk 有效的输出参数数目 realmax 最大正浮点数 realmin 最小正浮点数 varargin 实际输入 的参量 varargout 实际返回的参量 操作符与特殊字符 + 加实线 c 亮青色 : 点线 m 锰紫色-.点虚线--虚线

七、注解

xlabel('Input Value');% x轴注解 ylabel('Function Value');% y轴注解

title('Two Trigonometric Functions');% 图形标题

legend('y = sin(x)','y = cos(x)');% 图形注解 grid on;% 显示格线 八、二维绘图函数 bar 长条图

errorbar 图形加上误差范围 fplot 较精确的函数图形 polar 极座标图 hist 累计图

rose 极座标累计图 stairs 阶梯图 stem 针状图 fill 实心图 feather 羽毛图 compass 罗盘图 quiver 向量场图

第二篇:Matlab学习总结

学Matlab有感

姓名:王鸿栋 学号:20090286 班级: 03310901 我对于计算机编程接触的比较晚,也没有特别大的兴趣。不过对于Matlab这门课我还是很喜欢的。一是这个语言可以变出程序绘出函数的图形,这就使得这个语言可以被“看见”,感觉比较亲切,不是那么缥缈空虚的东西。二是这个语言却是很“友好”,很人性化,像我刚学习这门语言,还什么都不会编的时候,我随便打出了一句help,界面上就输出了帮助文档。三是这个语言的强大的功能,1.3G不是白给的,很多C、java里需要用循环语句来完成的,在Matlab里只需要一句话就可以搞定了,刚上这门课时老师说C一堂课讲授的内容Matlab一句话就可以搞定了,看来不是假的。四是这门语言确实很有用,信号与系统课上学的很多内容都可以用Matlab来仿真,另外这门语言在很多其他的领域也都很有用,所以,我打算好好学习这门语言。

第一次交作业时我还只交上了两道题,那时候对这门语言接触得还比较少,但是就在交作业的那天我打算好好学习这门语言,而且在写作业的时候我确实喜欢上了这门语言。虽然第一次由于时间仓促只交上了两道题,可是那都是我自己写的,我觉得只有这样才能学到东西。第二天,在别人都在做第二次作业的时候,我却仍然在做第一次作业,我打算把第一次的作业完整的写一遍,即使这对我的分数一点帮助也没有。第二次作业我提前好几天就写完了,虽然没有完成全部的题目。我把第一第二次作业一起交了上去,我希望老师能帮我看一看。

上面只是对这门课程的一些怀念,课程已经结束了,不过我会继续学习这门语言的。下面就针对这次作业的要求,给这门课提一些看法,毕竟这才是正题。MATLAB 产品族可以用来进行以下各种工作:

● 数值分析

● 数值和符号计算

● 工程与科学绘图

● 控制系统的设计与仿真

● 数字图像处理

● 数字信号处理

● 通讯系统设计与仿真

● 财务与金融工程

MATLAB 的应用范围非常广,包括信号和图像处理、通讯、控制系统设计、测试和测量、财务建模和分析以及计算生物学等众多应用领域。附加的工具箱(单独提供的专用 MATLAB 函数集)扩展了 MATLAB 环境,以解决这些应用领域内特定类型的问题。说实在的想完全掌握全部的基本上是不可能的,就像dsp一样,应用的范围很广,想一口吃可能不行,所以要结合专业来学习才好!

对于我们这些学习了C语言的学生,编程基本的语法学习起来很快的,和c语言很类似,而且是支持c语言函数的,或者说函数就是用c语言编的,完全是解释性的语言,像打草稿一样,可以一句句的编译,看结果的。

等我们编到基本的熟悉之后就可以编辑函数了,-------这个其实用的不多,为了应用的话,老师建议开始编写M文件,也就是把程序都写在m文件里面,然后编译,调试,根据错误信息来调试。

至于和专业相关的方面就说说自动化方面吧!和控制理论,fft,用的比较多,根轨迹,相平面,传递函数,拉普拉斯变换,奈氏曲线什么的,基本上都可以解决

03310901班

王鸿栋 20090286 对于授课方式,我觉得上课时老师是结合信号与系统来讲的,就是说课程的定位就是交给我们解决信号与系统方面问题的一个方法。我觉得Matlab功能远远不止于此。而且老师在课上讲程序都是一带而过,我觉得讲授的程序不必很多,一堂课只讲几个程序,但是对于每个程序,如果老师都能给我们进行分析,把这个程序将明白了,那么这堂课我们就能学到很多东西。而且这样讲课也不会使我们觉得枯燥。

对提高Matlab编程能力的方法,我想主要有以下三个: 1.查help 2.多上上论坛,搜索帖子、发帖子问人 3.阅读别人、特别是牛人的程序

当然了,正如所有的程序语言一样,“3分课本7分上机”,一定要动手才行,不能光看。多想、多思考、多尝试,才是正路。

最后,整理一下常用的快捷键(用【】表示)或命令: 1.在命令窗口(Command Window)中:

1)【上、下键】――切换到之前、之后的命令,可以重复按多次来达到你想要的命令 2)clc――清除命令窗口显示的语句,此命令并不清空当前工作区的变量,仅仅是把屏幕上显示出来的语句清除掉

3)clear――这个才是清空当前工作区的变量命令,常用语句clear all来完成

4)【Tab】键――(在command窗口,输入一个命令的前几个字符,然后按tab键,会弹出前面含这几个字符的所有命令,找到你要的命令,回车,就可以自动完成。目前讨论结果是:Matlab6.5版本中,如果候选命令超过100个,则不显示。而在Matlab7以后版本中,则没有这个限制,均可正常提示

5)【Ctrl+C】(或【Ctrl+Break】)――在Matlab程序运行过程中,可能由于程序编写的失误,导致程序不停的运行,在命令窗口输入“Ctrl+C”可以将运行的程序停下来,而不需要将整个Matlab程序关掉。不过进行此操作的前提是能够激活切换到命令窗口才行,呵呵。

2.在编辑器(Editor)中: 1)【Tab】(或【Ctrl+]】)――增加缩进(对多行有效)2)【Ctrl+[】--减少缩进(对多行有效)

3)【Ctrl+I】--自动缩进(即自动排版,对多行有效)4)【Ctrl+R】――注释(对多行有效)5)【Ctrl+T】――去掉注释(对多行有效)

6)【Ctrl+B】――括号配对检查(对版本6.5有效,但版本7.0无效,不知道是取消了还是换了另外的快捷键,请大牛们指点,其他版本没有测试过)

7)【F12】――设置或取消断点 8)【F5】――运行程序

其余的例如在Debug状态下的快捷键可以自己看菜单。

就说这么多,通过这个小学期,我觉得自己真的学到了很多!

03310901班

王鸿栋 20090286

第三篇:matlab总结

班级: 学号: 姓名:

Matlab学习综述

MATLAB是一种科学计算软件,专门以矩阵的形式处理数据。MATLAB将高性能的数值计算和强大的数据可视化功能集成在一起,并提供了大量的内置函数,从而被广泛地应用于科学计算、控制系统、信息处理等领域的分析、仿真和设计工作,而且利用MATLAB产品的开放式结构,可以非常容易地对MATLAB的功能进行扩充。

MATLAB产品由若干个模块组成,不同的模块完成不同的功能,其中主要的核心模块有MATLAB、MATLAB Toolboxex、MATLAB Compiler Simulink、Simulink Blocksets、Real-time Workshop(RTW)Stateflow。这些产品大体上可以分为以MATLAB为基础的产品和以Simulink为基础的产品两大分支。其中,MATLAB是MATLAB产品家族的基础,任何其他MATLAB产品产品都以这个模块为基础。MATLAB的桌面应用程序开发工具是以MATLAB Compiler为核心的一组编译工具。Simulink是基于MATLAB的框图设计环境,可以用来对各种动态系统进行建模,分析和仿真,它的建模范围广泛,可以针对任何能够用数字来描述的系统进行建模。

一种完整的计算机应用语言应该提供对数据的描述和对数据的操作。在M语言中,最常用的数据类型表现手段和形式就是变量和常量,由于MATLAB软件自身的特点,它是一种以数值计算为基础的软件,因此M语言的基本处理单位是数值矩阵或者数值向量,在M语言中统一将矩阵或者向量称之为数组,因此掌握一些基本的矩阵、向量和数组操作的基本知识就成为了掌握MATLAB软件的基础。变量和常量是编程语言中类型的表现手段和形式,掌握变量和常量的概念也是掌握M语言编程的基础。所谓变量,就是指在程序运行中需要改变数值的量,每一个变量都具有一个名字,变量将在内存中占据一定的空间,以在程序运行的过程中保存其数值,对变量的命名有相应的要求:变量必须以字母开头,后面可以是字母、数字或者下划线之间的组合。所谓常量就是在程序运行的过程中不需要改变数值的量。

MATLAB专门以矩阵作为基本的运算单位,首先要掌握向量、矩阵、索引和多维数组的概念,以及在MATLAB环境下创建向量、矩阵和多维数组的方法,以及操作矩阵和多维数值的函数的使用方法。

目前的MATLAB版本中不仅有多达十几种的基本数据类型。在不同的专业工具箱中还有特殊的数据类型,并且MATLAB还支持面向对象的编程技术,支持用户自定义的数据类型。获取MATLAB的数据类型可以在MATLAB命令行窗体中键入help datatypes。MATLAB的数据类型包括基本的数值类型,逻辑类型数据、元胞数值、结构和字符串等,需要指出一点,MATLAB的基本数据是双精度数据类型和字符类型。MATLAB提供了完整的编写应用程序的功能,这种能力被称为M语言的高级语言来实现。这种语言是一种解释性语言,利用该语言编写的代码仅能被MATLAB接受,被MATLAB解释执行。其实,一个M语言文件就是由若干MATLAB的命令组合在一起构成的,和C语言类似。M语言文件都是标准的纯文本格式的文件,其文件的扩展名为.m。MATLAB的函数主要有两类,一类被称为内建函数,这类函数是由MATLAB的内核提供的,能够完成基本的运算,例如三角函数、矩阵运算函数等。另外一类函数就是利用高级语言开发的函数文件,这里的函数文件包括用C/FORTRAN语言开发的MEX函数文件,也包括了M函数文件。

M语言文件可以分为两类,其中一类是脚本文件,另一类是函数文件,脚本文件是最简单的一种M语言文件。所谓脚本文件就是由一系列的M语言文件指令和命令组成的纯文本格式的M文件,执行脚本文件时,文件中的指令或者命令按照出现在脚本文件中的顺序依次执行。脚本文件没有输入参数,也没有输出参数,脚本文件处理的数据或者变量必须在MATLAB的公共工作空间中,脚本文件主要是由注视行和代码行组成。

函数文件是M文件最重要的组成部分,M语言函数文件能够接受用户的输入参数,并进行计算,然后将计算结果作为函数的返回值返回给调用者,M函数文件和脚本文件不同,函数文件不仅有自己特殊的文件格式,而且不同的函数还分别具有自己的工作空间,函数文件的输/输出参数不同,这些输入/输出参数在定义的时候不需要指出变量的类型,因为MATLAB默认这些参数都使用双精度类型,这样可以简化程序的编写。M语言的函数文件不仅可以有一个输入参数和一个返回值,还可以为M语言函数文件定义多个输入参数和多个输出参数,同一个M函数文件中可以包含多个函数。如果在同一个M函数文件中包含了多个函数,那么将出现在文件中的第一个M函数称为主函数,其余的函数称为子函数。

经过这么一段时间的学习,对MATLAB有了初步的认识。但是关于它还有很多知识我们所不知道,还有待进一步的学习。以上内容是我对这学期所学课程的总结,可能有些地方总结的不够到位,因为有些地方学习的不够深入,所以,以后要更加努力,在MATLAB的学习上多花一些时间,为以后的学习和工作打下基础。

第四篇:MATLAB总结

目录

一、Matlab相关说明.....................................................................2

二、Matlab操作注意事项..............................................................2

三、Matlab常用代码(图像处理相关)......................................5

四、Matlab常用快捷键.................................................................7

五、Matlab学习心得.....................................................................8

一、Matlab相关说明

Matlab是“Matrix Laboratory”的缩写,意为“矩阵实验室”。MATLAB和Mathematica、Maple并称为三大数学软件。它在数学类科技应用软件中在数值计算方面首屈一指。MATLAB可以进行矩阵运算、绘制函数和数据、实现算法、创建用户界面、连接其他编程语言的程序等,主要应用于工程计算、控制设计、信号处理与通讯、图像处理、信号检测、金融建模设计与分析等领域。

MATLAB的基本数据单位是矩阵,它的指令表达式与数学、工程中常用的形式十分相似,故用MATLAB来解算问题要比用C,FORTRAN等语言完成相同的事情简捷得多,并且MATLAB也吸收了像Maple等软件的优点,使MATLAB成为一个强大的数学软件。在新的版本中也加入了对C,FORTRAN,C++,JAVA的支持。

我所使用的Matlab版本是2012a,下文所涉及到图片、专业术语等都是以此版本为基础。

二、Matlab操作注意事项

1.打开并运行一个现存的m文件且这个m文件运行时需用到同一级文件夹中的其他文件,会出现如下提示框:

选择变更文件夹,将当前文件夹变更为这个m文件所在的文件夹。

2.不小心点错或关闭了各种小窗口,将Matlab恢复成默认布局

点击桌面—桌面布局—默认

3.查看某个函数的用法

在命令窗口输入该变量的名称,回车即可。

4.查找某个函数的用法

在命令窗口输入help+函数的名称,回车后会自动显示该函数的相关信息。

5.运行文件后报错 如下图所示,命令窗口中报错的第一段是错误的原因,后面几段会显示发生错误的文件夹以及在该文件夹中的位置。

点击文件的名称,会跳转出一个提示框,上面显示了该文件的具体实现功能,如下图所示。点击文件名后面的行标号,可以直接跳转到发生错误的那一行。

6.如何编辑界面?

修改如图所示的fig文件

1.新建一个GUI文件

2.选择打开现存的GUI文件,点击Open,就可以对当前界面进行编辑了。

7.如何将MAtlab中默认的current folder修改为自己想要的路径,每次启动后都默认是自己 设定的这个路径?

>>右键matlab 快捷方式,属性-快捷方式-起始位置 填入你自己的工作目录。8.把图复制到WORD文件的方法:电机EDIT—>Copy Figure—>Ctrl+V 9.输入时,标点必须是英文状态下的

10.大多数情况下,matlab对空格不予处理

11.小括号代表运算级别,中括号用于生成矩阵,大括号用于构成单元数组

12.分号;的作用:不显示运算结果,但对图形窗口不起作用。分号也用于区分行,13.逗号,的作用:函数参数分隔符,也用于区分行,显示运算结果,当然不加标点也显示运算结果

14.冒号:多用于数组

15.续行号...不能放在等号后面使用,不能放在变量名中间使用,起作用时默认显蓝色 16.双引号'string'是字符串的标识符 17.感叹号!用于调用操作系统运算

18.百分号%是注释号,百分号后面直到行末的语句matlab跳过执行.另外还有一个块注释,即对多行一次注释,会使用到,格式为(注意%{ 和%}都要单独成行)%{ %} 19.矩阵中用圆括号表示下标,单元数组用大括号表示下标

20.对变量名的基本要求:区分大小写,不超过63个字符,以字母开头,只能是字母,数字和下划线

三、Matlab常用代码(图像处理相关)

1.创建一个文件夹 mkdir('D:myData');2.将图片保存到指定的文件夹

image_source=strcat('result',num2str(loop),'.jpg');imwrite(F.cdata,image_source);3.将电影转成图片序列

fnum=size(mov,2);%读取电影的祯数 for i=1:fnum strtemp=strcat('C:UsersAdministratorDesktopparticalfiltermyself粒子滤波',int2str(i),'.jpg');%将每祯转成jpg的图片 imwrite(mov(i).cdata,strtemp,'jpg');end

4、模拟噪声生成函数和预定义滤波器

① imnoise:用于对图像生成模拟噪声,如:

i=imread('104_8.tif');j=imnoise(i,'gaussian',0,0.02);%模拟高斯噪声 ② fspecial:用于产生预定义滤波器,如: h=fspecial('sobel');%sobel水平边缘增强滤波器 h=fspecial('gaussian');%高斯低通滤波器 h=fspecial('laplacian');%拉普拉斯滤波器

h=fspecial('log');%高斯拉普拉斯(LoG)滤波器 h=fspecial('average');%均值滤波器

5、图像文件I/O函数命令

imfinfo 返回图形图像文件信息

语法:info=imfinfo(filename,fmt)info=imfinfo(filename)imread 从图像文件中读取(载入)图像

语法:A=imread(filename,fmt)[X,map]=imread(filename,fmt)[...]=imread(filename)[...]=imread(URL,...)[...]=imread(...,idx)(CUR,ICO,and TIFF only)[...]=imread(...,'frames',idx)(GIF only)[...]=imread(...,ref)(HDF only)[...]=imread(...,'BackgroundColor',BG)(PNG only)[A,map,alpha] =imread(...)(ICO,CUR,PNG only)imwrite 把图像写入(保存)图像文件中

语法:imwrite(A,filename,fmt)imwrite(X,map,filename,fmt)imwrite(...,filename)imwite(...,Param1,Val1,Param2,Val2...)imcrop 剪切图像

语法:I2=imcrop(I)X2=imcrop(X,map)RGB2=imcrop(RGB)I2=imcrop(I,rect)X2=imcrop(RGB,rect)[...]=imcrop(x,y,...)[A,rect]=imcrop(...)[x,y,A,rect]=imcrop(...)

6.impixel 确定像素颜色值

语法:P=impixel(I)P=impixel(X,map)P=impixel(RGB)P=impixel(I,c,r)P=impixel(X,map,c,r)P=impixel(RGB,c,r)[c,r,P]=impixel(...)P=impixel(x,y,I,xi,yi)P=impixel(x,y,RGB,xi,yi)P=impixel(x,y,X,map,xi,yi)[xi,yi,P]=impixel(x,y,...)

7.二进制图像操作函数

applylut 在二进制图像中利用lookup表进行行边沿操作 语法:A=applylut(BW,LUT)bwarea 计算二进制图像对象的面积 语法:total=bwarea(BW)bweuler 计算二进制图像的欧拉数 语法:eul=bweuler(BW)

8.颜色空间转换函数

hsv2rgb 转换HSV值为RGB颜色空间:M=hsv2rgb(H)ntsc2rgb 转换NTSC值为RGB颜色空间:rgbmap=ntsc2rgb(yiqmap)RGB=ntsc2rgb(YIQ)rgb2hsv 转换RGB值为HSV颜色空间:cmap=rgb2hsv(M)rgb2ntsc 转换RGB值为NTSC颜色空间:yiqmap=rgb2ntsc(rgbmap)YIQ=rgb2ntsc(RGB)rgb2ycbcr 转换RGB值为YCbCr颜色空间:ycbcrmap=rgb2ycbcr(rgbmap)YCBCR=rgb2ycbcr(RGB)ycbcr2rgb 转化YCbCr值为RGB颜色空间:rgbmap=ycbcr2rgb(ycbcrmap)RGB=ycbcr2rgb(YCBCR)

9.类型转换函数

im2bw 转换图像为二进制图像

语法:BW=im2bw(I,level)BW=im2bw(X,map,level)BW=im2bw(RGB,level)im2double 转换图像矩阵为双精度型

语法:I2=im2double(I1)RGB2=im2double(RGB1)I=im2double(BW)X2=im2double(X1,'indexed')double 转换数据为双精度型 语法:double(X)unit8、unit16转换数据为8位、16位无符号整型: i=unit8(x)i=unit16(x)im2unit8 转换图像阵列为8位无符号整型

语法:I2=im2unit8(I1)RGB2=im2unit8(RGB1)I=im2unit8(BW)X2=im2unit8(X1,'indexed')im2unit16 转换图像阵列为16位无符号整型

语法:I2=im2unit16(I1)RGB2=im2unit16(RGB1)I=im2unit16(BW)X2=im2unit16(X1,'indexed')

四、Matlab常用快捷键

1.在命令窗口(Command Window)中:

1)【上、下键】――切换到之前、之后的命令,可以重复按多次来达到你想要的命令

2)clc――清除命令窗口显示的语句,此命令并不清空当前工作区的变量,仅仅是把屏幕上显示出来的语句清除掉

3)clear――这个才是清空当前工作区的变量命令,常用语句clear all来完成 4)【Tab】键――在command窗口,输入一个命令的前几个字符,然后按tab键,会弹出前面含这几个字符的所有命令,找到你要的命令,回车,就可以自动完成。目前讨论结果是:matlab6.5版本中,如果候选命令超过100个,则不显示。而在matlab7以后版本中,则没有这个限制,均可正常提示 5)【Ctrl+C】(或【Ctrl+Break】)――在matlab程序运行过程中,可能由于程序编写的失误,导致程序不停的运行,在命令窗口输入“Ctrl+C”可以将运行的程序停下来,而不需要将整个Matlab程序关掉。不过进行此操作的前提是能够激活切换到命令窗口才行。6)edit+函数名 查看或编辑源文件 7)who 显示当前变量名列表 8)whos 显示变量详细列表

9)which+函数名 证实该函数是否在当前路径 10)what 列出当前路径的所有matlab文件 11)load 加载外部文件 12)save 保存文件到外部 13)20.matlab的帮助函数: 14)help 15)help+函数名或help+函数类名 精确查询 16)helpwin 打开帮助窗口 17)helpwin+函数名 精确查询 18)helpdesk 打开帮助窗口 19)doc 打开帮助窗口

20)doc+函数名 打开帮助窗口,精确查询

21)lookfor+关键字 这个是matlab中的谷歌,模糊查询

2.在编辑器(Editor)中: 1)【Tab】(或【Ctrl+]】)――增加缩进(对多行有效)2)3)4)5)6)【Ctrl+[】--减少缩进(对多行有效)

【Ctrl+I】--自动缩进(即自动排版,对多行有效)【Ctrl+R】――注释(对多行有效)【Ctrl+T】――去掉注释(对多行有效)

【Ctrl+B】――括号配对检查(对版本6.5有效,但版本7.0无效,不知道是取消了还是换了另外的快捷键,请大牛们指点,其他版本没有测试过)7)【F12】――设置或取消断点 8)【F5】――运行程序

五、Matlab学习心得

接触Matlab一个多月,从刚开始连最基本的操作都不会,到现在能够熟练地运用Matlab解决问题。虽然现在学到的也只是皮毛而已,离精通还相差甚远,但至少为以后研究生期间的学习打下了良好的基础。下面我就简单的谈一下这一个月来的学习感想。

首先,想要学好Matlab必须有一定数学基础。Matlab软件是与高等数学,计算机科学相结合的软件。所以,当你学习Matlab时,你也得会一定的数学。你要尽量多的熟悉matlab自带的函数,及其作用,因为matlab的自带函数特别多,基本上能够满足一般的数据和矩阵的计算,所以基本上不用你自己编函数。这一点对你的程序非常有帮助,可以使你的程序简单,运行效率高,可以节省很多时间。

其次,要注重基础知识于实际操作结合。你把基本的知识看过之后,就需要找一个实际的程序来动手编一下,不要等所有的知识都学好之后再去编程,你要在编程的过程中学习,程序需要什么知识再去补充。在遇到问题时,不要光看别人如果解决,也不要光想怎么解决,自己坐下来,动手自己解决一下,那你就会把不是你的知识变成自己的知识。

最后,也是最重要的一点就是坚持。MATLAB涉及的领域太多,每个领域里面都缺乏足够的专家分布在你周围。那么我们很难有机会接触到真正的高手,对我们的技术细节一一指点。在遇到实际问题时,就只能靠自己去摸索。常常是再坚持一两个小时,就能够解决你的问题。最大的成就感,就在付出了极大的心血和耐心,才取得一个艰难的小胜利。

第五篇:关于“Matlab Demos”的学习和总结

关于“Matlab Demos”的学习和总结

这里总结了Matlab Demos下通信工具箱里面的examples,给出源代码和注释。

程序代码(一):关于BPSK的Mente Carlo仿真

%-----------% Matlab Demos

No.1.1 %-----------% Phase Shift Keying Simulation % This demo shows how to simulate a basic Quarternary Phase Shift Keying %(QPSK)communication link, and to generate empirical performance curves % that can be compared to theoretical predictions.%-----------% 1.两个函数的使用:rectpulse与intdump成对使用,重复插值与抽取,互为逆操作; % 2.randn的seed的使用;

% 3.这里的解调是直接采用MATLAB自带的pskmod、pskdemod函数;

% 4.为什么在后面调用函数,当采用的EbNo越大的时候,计算需要的时间越长?甚至是

%

系统死机(大概超过10dB之后)?

% 5.这里需要讨论的问题就是 Mente Carlo 仿真的数值问题,即当用一个试验样本函数去

%

估计一个观测值的时候,如何尽量减小估计值的方差问题(选择合适的仿真点总数和期望错误点数)。%-----------%

revised by lavabin 2006.07.26 %-----------clc;clear all;close all;echo off;tic;%-----------%

Parameter Definition %-----------nSamp = 8;numSymb = 100;

M = 4;SNR = 14;

seed = [12345 54321];

rand('state', seed(1));randn('state', seed(2));%-----------%

Generating random information symbols %-----------numPlot = 10;rand('state', seed(1));msg_orig = randsrc(numSymb, 1, 0:M-1);%-----------% Phase modulating the data

% Use PSKMOD to phase modulate the data and RECTPULSE to upsample to a % sampling rate 8 times the carrier frequency.%-----------grayencod = bitxor(0:M-1, floor((0:M-1)/2));

% Gray coding here!% % a = bitxor(0:M-1, floor((0:M-1)/2))% % a = 0 msg_gr_orig = grayencod(msg_orig+1);% % Using “looktable” to map source data to Gray code msg_tx = pskmod(msg_gr_orig,M);% % Mapping source data to MPSK constellation msg_tx = rectpulse(msg_tx,nSamp);%-----------------------------% figure(1);%-----------------------------scatterplot(msg_tx);hold on;grid on;%-----------% Creating the noisy signal % Then use AWGN to add noise to the transmitted signal to create the noisy % signal at the receiver.Use the 'measured' option to add noise that is % 14 dB below the average signal power(SNR = 14 dB).Plot the % constellation of the received signal.%-----------randn('state', seed(2));msg_rx = awgn(msg_tx, SNR, 'measured', [], 'dB');%-----------------------------% figure(2);

%-----------------------------scatterplot(msg_rx);hold on;grid on;%-----------% Recovering information from the transmitted signal % Use INTDUMP to downsample to the original information rate.Then use % PSKDEMOD to demodulate the signal, and detect the transmitted symbols.% The detected symbols are plotted in red stems with circles and the % transmitted symbols are plotted in blue stems with x's.The blue stems of % the transmitted signal are shadowed by the red stems of the received % signal.Therefore, comparing the blue x's with the red circles indicates % that the received signal is identical to the transmitted signal.%-----------msg_rx_down = intdump(msg_rx,nSamp);% operation before DEMOD msg_gr_demod = pskdemod(msg_rx_down,M);[dummy graydecod] = sort(grayencod);graydecod = graydecod(11;% Drive the simulation for each of the SNR values calculated above for idx2 = 1:length(EsNo)

% Exit loop only when minimum number of iterations have completed and the

% number of errors exceeds 'expSymErrs'

idx = 1;

while((idx <= iters)||(sum(errSym)<= expSymErrs))% ||--> logical or %

while(idx <= iters)

% Generate random numbers from in the range [0, M-1]

msg_orig = randsrc(symbPerIter, 1, 0:M-1);

% Gray encode symbols

msg_gr_orig = grayencod(msg_orig+1)';

% Digitally modulate the signal

msg_tx = pskmod(msg_gr_orig, M);

% Add Gaussian noise to the signal.The noise is calibrated using

% the 'measured' option.msg_rx = awgn(msg_tx, EsNo(idx2), 'measured', [], 'dB');

% Demodulate the signal

msg_gr_demod = pskdemod(msg_rx, M);

% Gray decode message

msg_demod = graydecod(msg_gr_demod+1)';

% Calculate bit error count, BER, symbol error count and SER,% for this iteration.[errBit(idx)ratBit(idx)] = biterr(msg_orig, msg_demod, k);

[errSym(idx)ratSym(idx)] = symerr(msg_orig, msg_demod);

% Increment for next iteration

idx = idx + 1;

end

% average the errors and error ratios for the iterations.errors(idx2, :)= [sum(errBit), sum(errSym)];

ratio(idx2, :)= [mean(ratBit), mean(ratSym)];% %

函数说明 mean:

% %

MEAN

Average or mean value.% %

For vectors, MEAN(X)is the mean value of the elements in X.For % %

matrices, MEAN(X)is a row vector containing the mean value of % %

each column.% Plot the simulated results for SER and BER.semilogy(EbNo(1:size(ratio(:,2),1)), ratio(:,2), 'bo',...EbNo(1:size(ratio(:,1),1)), ratio(:,1), 'ro');

legend('Theoretical SER','Theoretical BER','Simulated SER','Simulated BER',0);

drawnow;end hold off;%-----------%

End of Function %-----------% % 函数说明:

% % DRAWNOW Flush pending graphics events.% %

DRAWNOW “flushes the event queue” and forces MATLAB to % %

update the screen.% %

% %

There are four events that cause MATLAB to flush the event % %

queue and draw the screen: % %

% %

-a return to the MATLAB prompt % %

-hitting a PAUSE statement % %

-executing a GETFRAME command % %

-executing a DRAWNOW command

程序代码(二): 程序代码(三): 关于升余弦滤波器

%-----------% Matlab Demos

No.3.1 %-----------% Raised Cosine Filtering %-----------%(1)% This demonstration uses the Communications Toolbox functions, RCOSINE and % RCOSFLT, to demonstrate the ISI rejection capability of the raised cosine % filter.%(2)% It demonstrates how to use RCOSINE and RCOSFLT, how the raised cosine

% filter controls intersymbol interference, and how to split % the raised cosine filtering between transmitter and receiver.%(3)% This data sequence represents a digital sequence that will be upsampled by % zero-padding before filtering.Raised cosine filters will be used to shape % the waveform without introducing intersymbol interference(ISI).%-----------% 几点主要的意思:

% 1

“升余弦函数 rcosine” 和 “升余弦滤波器函数 rcosflt”的使用;

% 2

波形成形的目标是在源端就利用升余弦函数的抗ISI特性消除ISI,因为不可能生成 %

绝对的的时域有限的信号; % 3

升余弦滤波器在源/宿端的分割。% % 从上到下几个code板块依次讨论了: % % Delay的影响 % % R的影响

% % 发、收端之间平方根升余弦滤波 % % 缺省方式下的rcosflt的快速调用方法

%-----------%

revised by lavabin 2006.08.02 %-----------clc;clear all;close all;echo off;tic;%-----------%

Parameter Definition %-----------Delay = 3;DataL = 20;R =.5;Fd = 1;Fs = 8;PropD = 0;% Generate random data.x = randsrc(DataL, 1, [], 1245);% at time 0, 1/Fd, 2/Fd,...% Fd is the sampling frequency of the data source % 1/Fd is the symbol period of the data source tx = [PropD: PropD + DataL1]./ Fd;% figure(2)% figure1 与 figure2的波形对比强烈地反映出了Delay的作用,滤波器输出的波形与输入

% 波形在包络上的相似性需要通过延迟输入信号来得到保证 figure;stem(tx, x, 'kx');hold on;plot(to, yo, 'b.');hold off;axis([0 30-1.6 1.6]);xlabel('Time');ylabel('Amplitude');%-----------% This step demonstrates the effect that changing the rolloff factor from.5 %(blue curve)to.2(red curve)has on the resulting filtered output.The % lower value for rolloff causes the filter to have a narrower transition band % causing the filtered signal overshoot to be greater for the red curve than for % the blue curve.%----------% Design filter.[yg, tg] = rcosine(Fd, Fs, 'fir',.2, Delay);% Filter data.[yo1, to1] = rcosflt(x, Fd, Fs, 'normal/fir/filter',yg);% figure(3)figure;stem(tx, x, 'kx');hold on;% Plot filtered data.plot(to, yo, 'b-',to1, yo1, 'r-');hold off;% Set axes and labels.axis([0 30-1.6 1.6]);xlabel('Time');ylabel('Amplitude');legend('Source Data','R = 0.5','R = 0.2')%-----------% A typical use of raised cosine filtering is to split the filtering between % transmitter and receiver.The data stream is upsampled and filtered at the % transmitter using the square-root raised cosine filter.This plot shows % the transmitted signal when filtered using the square-root raised cosine % filter.The “fir/sqrt” switch was used with RCOSINE to generate the % square-root raised cosine filter.%-----------% Design square root filter.[ys, ts] = rcosine(Fd, Fs, 'fir/sqrt', R, Delay);% Filter at the transmitter.[yc, tc] = rcosflt(x, Fd, Fs, 'filter', ys);% figure(4)figure;stem(tx, x, 'kx');hold on;plot(tc, yc, 'm.');hold off;axis([0 30-1.6 1.6]);xlabel('Time');ylabel('Amplitude');%-----------% The transmitted signal(magenta curve)is then filtered, but not upsampled, at % the receiver, using the same square-root raised cosine filter, resulting in a % signal depicted by the blue curve at the receiver.The resulting signal is % virtually identical to the signal filtered using a single raised cosine % filter.The “Fs” was used to filter without upsampling.%-----------% Filter at the receiver.[yr, tr] = rcosflt(yc, Fd, Fs, 'filter/Fs', ys);% Adjust for propagation delay.tcc = tc + Delay.* Fd;txx = tx + Delay.* Fd;% figure(5)figure;stem(txx, x, 'kx');hold on;plot(tcc, yc, 'm-',tr, yr, 'b-');hold off;axis([0 30-1.6 1.6]);xlabel('Time');ylabel('Amplitude');%-----------% This step demonstrates a quicker way to filter data using RCOSFLT.When % RCOSFLT is used without the “filter” type switch, it designs a filter and uses % it to filter the input data.This step creates the same plot as before but % designs the raised cosine filter and generates the filtered stream in one % command.%-----------% Design and filter.[yo2, to2] = rcosflt(x, Fd, Fs, 'normal/fir', R, Delay);% figure(6)figure;stem(tx, x, 'kx');hold on;plot(to2, yo2, 'b-');hold off;axis([0 30-1.6 1.6]);xlabel('Time');ylabel('Amplitude');%-----------displayEndOfDemoMessage(mfilename)%-----------simulation_time = toc %-----------%

End of Script %-----------% % 关于rcosflt的函数说明

%-----------% % RCOSFLT Filter the input signal using a raised cosine filter.% %

Y = RCOSFLT(X, Fd, Fs, TYPE_FLAG, R, DELAY)filters the input signal X % %

using a raised cosine FIR filter.The sample frequency for the input, X, % %

is Fd(Hz).The sample frequency for the output, Y, is Fs(Hz).Fs must be % %

an integer multiple of Fd.The TYPE_FLAG gives specific filter design % %

or filtering options.The rolloff factor, R, determines the width of the % %

transition band of the filter.DELAY is the time delay from the beginning % %

of the filter to the peak of the impulse response.% %

% %

R, the rolloff factor specifies the excess bandwidth of the filter.R must % %

be in the range [0, 1].For example, R =.5 means that the bandwidth of the % %

filter is 1.5 times the input sampling frequency, Fd.This also means that % %

the transition band of the filter extends from.5 * Fd and 1.5 * Fd.Since % %

R is normalized to the input sampling frequency, Fd, it has no units.% %

Typical values for R are between 0.2 to 0.5.% %

% %

DELAY determines the group delay of the filter.The group delay is the % %

opposite of the change in filter phase with respect to frequency.For linear % %

phase filters, the group delay is also the time delay between the input % %

signal and the peak response of the filter.DELAY also determines the % %

length of the filter impulse response used to filter X.This delay is % %

Fs/Fd *(2 * DELAY + 1).% %

% %

Y is the output of the upsampled, filtered input stream X.The length of % %

vector Y is % %

Fs/Fd *(length(X)+ 2 * DELAY).% %

% %

TYPE_FLAG is a string which may contain any of the option strings listed % %

below delimited by a '/' For example, the 'iir' and 'Fs' flags may % %

be combined as 'iir/Fs'.While some of the pairs of option substrings % %

are mutually exclusive, they are not mutually exclusive in general.% % % %

'fir'

Design an FIR filter and use it to filter X.When the 'filter' % %

TYPE_FLAG is not used, an FIR filter is designed and used to % %

filter X.See the 'filter' TYPE_FLAG description for the behavior % %

when the 'fir' and 'filter' TYPE_FLAGs are used together.This % %

option is exclusive of the 'iir' substring.% %

% %

'iir'

Design an IIR filter and use it to filter X.When the 'filter' % %

TYPE_FLAG is not used, an IIR approximation to the equivalent FIR % %

filter is designed and used to filter X.See the 'filter' % %

TYPE_FLAG description for the behavior when the 'iir' and 'filter' % %

TYPE_FLAGs are used together.This option is exclusive of the % %

'fir' substring.% % % %

'normal' Design a normal raised cosine filter and use it to filter X.The % %

filter coefficients are normalized so the peak coefficient is one.% %

This option is exclusive of the 'sqrt' substring.% %

% %

'sqrt'

Design a square root raised cosine filter and use it to filter X.% %

The filter coefficients are normalized so that the impulse % %

response of this filter when convolved with itself will result % %

in an impulse response that is approximately equal to the 'normal' % %

raised cosine filter.The difference in this approximation is due % %

to finite filter length.This is a useful option when the raised % %

cosine filtering is split between transmitter and receiver by % %

using the 'sqrt' filter in each device.This option is exclusive % %

of the 'normal' substring.% %

% %

'Fs'

X is input with sample frequency Fs(i.e., the input signal has % %

Fs/Fd samples per symbol).In this case the input signal is not % %

upsampled from Fd to Fs but is simply filtered by the raised % %

cosine filter.This is useful for filtering an oversampled data % %

stream at the receiver.When using the 'Fs' substring, the length % %

of vector, Y is % %

length(X)+ Fs/Fd * 2 * DELAY.% %

% %

'filter' Means the filter is provided by the user.When using the 'filter' % %

TYPE_FLAG, the input parameters are: % %

% %

Y = RCOSFLT(X, Fd, Fs, TYPE_FLAG, NUM)filters with % %

a user-supplied IIR filter.When TYPE_FLAG contains both 'filter' % %

and 'iir' type substrings, the IIR filter defined by numerator, % %

NUM, and denominator, DEN, is used as to filter X.The DELAY % %

parameter is used to force RCOSFLT to behave as if the filter were % %

designed by RCOSFLT using the same DELAY parameter.The DELAY % %

parameter should match the DELAY parameter used to design the % %

filter defined by NUM and DEN in the RCOSINE function.The default % %

value of DELAY is 3.% %

% %

The raised cosine filter should be designed using the RCOSINE % %

function.% %

% %

Y = RCOSFLT(X, Fd, Fs, TYPE_FLAG, R)filters the input signal X % %

using a raised cosine filter and default DELAY parameter, 3.% %

% %

Y = RCOSFLT(X, Fd, Fs, TYPE_FLAG)filters the input signal X using a % %

raised cosine filter and the following default parameters % %

DELAY = 3 % %

R =.5 % %

% %

Y = RCOSFLT(X, Fd, Fs)filters the input signal X using a raised cosine % %

filter and the following default parameters % %

DELAY = 3 % %

R =.5 % %

TYPE_FLAG = 'fir/normal' % %

% %

Y = RCOSFLT(X, Fd, Fs, TYPE_FLAG, R, DELAY, TOL)specifies the % %

tolerance in IIR filter design.The default value for TOL is.01.% %

% %

[Y, T] = RCOSFLT(...)returns the time vector in T.%-----------

下载学习matlab总结(定稿)word格式文档
下载学习matlab总结(定稿).doc
将本文档下载到自己电脑,方便修改和收藏,请勿使用迅雷等下载。
点此处下载文档

文档为doc格式


声明:本文内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:645879355@qq.com 进行举报,并提供相关证据,工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。

相关范文推荐

    matlab学习心得体会

    Matlab学习心得 班级:机械124 姓名:万明男学号:2012093386 电话:*** matlab学习心得体会 MATLAB中有丰富的图形处理能力,提供了绘制各种图形、图像数据的函数。他提供......

    matlab学习心得体会

    最近在学习matlab,一直不入其法门。从网上看到了一些大虾的经验心得,感触颇深,转贴过来,希望给初学者有一定的指引。一)写给学习matlab 的新手们 作者:eight (八) 来源振动论坛......

    matlab学习心得体会

    数值运算 1.cd显示当前的工作目录,dir列出当前目录下的子文件或子目录,home将光标移动到左上角,type列出所有的文件内容。 2.特殊矩阵的生成: 3.linspace生成矩阵: (1)linspace(a,b......

    MATLAB学习感想

    学习感想 环科141 11 邢碧枞 在科技飞速发展的今天,各行各业都离不开计算机的使用,而作为以科研为主的环境科学,更是离不开对计算机及软件的学习。在这几周的课上,我们分别学习......

    MATLAB 学习部分总结及注意事项(五篇材料)

    MATLAB 绘制实测下沉曲线注意事项 1. 对于x轴为距离的下沉曲线图绘制,可以将距离数据输入Excel中按列排成一列,如果命名为distance,使用时就在MATLAB软件中使用distance=xlsrea......

    Matlab常用指令总结

    概论 format long显示更多位数 format short显示少位数 format hex将数字显示为十六进制浮点数,(3fb999999999999a,a-f代表十六进制数,前三字符为) double()将数字转化为双精度浮......

    MATLAB知识总结

    1、命令x=0:0.2:2中的赋值格式是matlab常用的变量赋值格式,其中0表示初始值,0.2表示增量,而2表示终止值。若数组x无规律可循,那么x赋值得逐一输入单个元素了,这时要使用赋值格式......

    matlab基础总结

    Matlab程序设计的一般步骤: 1、陈述问题 2、定义输入和输出量 3、定义算法 4、把算法转化为matlab语句 5、检测产生的matlab程序 数组与变量: 1、数组中数据的访问a(行标 列标......