matlab

来源:互联网 发布:音频分轨软件 编辑:程序博客网 时间:2024/03/28 16:33

matlab打出上标用^比如要在上标max,则格式为^m^a^x

下标则为下划线( _ )


如果要打出下划线,因为默认下划线是用于打出下标的,需使用转义字符\反斜杠,比如\_ 即可输出下划线



matlab如何输出bar (即比如x上面的一横)

先用legend函数赋值给句柄h

h=legend('$\bar x$')

然后用latex的语法解析

set(h,'interpreter','latex')


比如

h=legend('$\bar k$=0.1‘,1)
set(h,'interprete','latex')



(2)matlab如何生成元素相同的矩阵/数组

若需生成全为0的矩阵,调用zeros函数即可

调用ones函数然后乘以相应的数即可

Y = ones(n) returns an n-by-n matrix of 1s. An error message appears if n is not a scalar.

Y = ones(m,n) or Y = ones([m n]) returns an m-by-n matrix of ones.

Y = ones(m,n,p,...) or Y = ones([m n p ...]) returns an m-by-n-by-p-by-... array of 1s.

比如要生成1*17的矩阵,矩阵中每个元素为24

则y=24*ones(1,17)


(3)linspace

Syntax
y = linspace(a,b)
y = linspace(a,b,n)

Description

The linspace function generates linearly spaced vectors. It is similar to the colon operator ":", but gives direct control over the number of points.

y = linspace(a,b) generates a row vector y of 100 points linearly spaced between and including a and b.

y = linspace(a,b,n) generates a row vector y of n points linearly spaced between and including a and b. For n < 2, linspace returns b.

调用linsapce(a,b)将在含a,b的闭区间创建100个线性空间排列(点与点之间间隔相等)的行向量

linspace(a,b,n)则是a,b的闭区间创建n个线性空间排列(点与点之间间隔相等)的行向量


遇到的问题1:

当把matlab生成的图形文件.fig保存后,尝试打开时发现无法打开。原因可能是你保存的文件路径中有中文或者文件名中含有中文


如何从.fig图像文件中导出数据

参考了http://zhidao.baidu.com/question/98375104.html

(1)在命令行输入obj = get(gca,'children')

get函数

Get object properties

get(h,'PropertyName') 

returns the value of the property 'PropertyName' of the graphics object identified by h.

gca为current axes handle
The current axes is the target for graphics output when you create axes children. The current axes is typically the last axes used for plotting or the last axes clicked on by the mouse

这个结果对应你的图里面的线或者面的句柄,有几条线就对应几个句柄。

(2)根据你需要的是哪条曲线,第n条线句柄就是obj(n),如果只有一个对象直接用obj就可以,
然后再用一次get,
x=get(obj(1), 'xdata');
y=get(obj(1), 'ydata');


如何使matlab输出的数字显示更多位的数字
可以在输出前使用format long


fig文件打开的时候目录包括文件名需要是英文的,否则无法正确识别



command history的内容如何拷贝,

command history内容全都存在如下文件中

如何找matlab的history文件

一般可在如下目录寻找

C:\Documents and Settings\Administrator\Application Data\MathWorks\MATLAB\R2008a\history.m

原创粉丝点击