直播365足球-beat365投注网站-bst365官网

Matlab学习笔记(1) - 符号变量及其运算

符号变量及其运算 绪:什么是符号计算? 1.字符型数据变量的创建 2.符号型数据变量的创建 3.符号计算的运算符与函数 4.寻找符号变量 5.符号精

Matlab学习笔记(1) - 符号变量及其运算

符号变量及其运算

绪:什么是符号计算?

1.字符型数据变量的创建

2.符号型数据变量的创建

3.符号计算的运算符与函数

4.寻找符号变量

5.符号精度计算

6.显示符号表达式

7.合并符号表达式

8.展开符号表达式

绪:什么是符号计算?

所谓符号计算是指在运算时,无须事先对变量赋值,而将所得到结果以标准的符号形式来表示。 例如,在符号变量运算过程中pi就用pi表示,而不是具体的近似数值在这里插入代码片3.14或3.1415926。使用符号变量进行运算能最大限度地减少运算过程中因舍入而造成的误差。符号变量也便于进行运算过程的演示。

1.字符型数据变量的创建

var = ‘expression

字符型变量是以矩阵的形式存在于Matlab的工作空间中的

示例

>> var = 'hello world'

var =

hello world

>> size(var)

ans =

1 11

>> y = '1 + sin(2*x)'

y =

1 + sin(2*x)

2.符号型数据变量的创建

符号对象中的符号常量、变量、函数和表达式,可以用sym和syms函数创建。使用class函数测试建立的操作对象为何种操作对象类型及是否为符号对象类型。

以下为Matlab自带的sym函数解释:

>> help sym

sym Construct symbolic numbers, variables and objects.

S = sym(A) constructs an object S, of class 'sym', from A.

If the input argument is a string, the result is a symbolic number

or variable. If the input argument is a numeric scalar or matrix,

the result is a symbolic representation of the given numeric values.

If the input is a function handle the result is the symbolic form

of the body of the function handle.

x = sym('x') creates the symbolic variable with name 'x' and stores the

result in x. x = sym('x','real') also assumes that x is real, so that

conj(x) is equal to x. alpha = sym('alpha') and r = sym('Rho','real')

are other examples. Similarly, k = sym('k','positive') makes k a

positive (real) variable. x = sym('x','clear') restores x to a

formal variable with no additional properties (i.e., insures that x

is NEITHER real NOR positive).

See also: SYMS.

A = sym('A',[N1 N2 ... Nk]) creates an N1-by-N2-...-by-Nk array of

symbolic scalar variables. Elements of vectors have names of the form Ai and elements

of matrices and higher-dimensional arrays have names of the form

Ai1_..._ik where each ij ranges over 1:Nj.

The form can be controlled exactly by using '%d' in the first

input (eg 'A%d%d' will make names Ai1i2).

A = sym('A',N) creates an N-by-N matrix.

sym(A,ASSUMPTION) makes or clears assumptions on A as described in

the previous paragraph.

Statements like pi = sym('pi') and delta = sym('1/10') create symbolic

numbers which avoid the floating point approximations inherent in the

values of pi and 1/10. The pi created in this way temporarily replaces

the built-in numeric function with the same name.

S = sym(A,flag) converts a numeric scalar or matrix to symbolic form.

The technique for converting floating point numbers is specified by

the optional second argument, which may be 'f', 'r', 'e' or 'd'.

The default is 'r'.

'f' stands for 'floating point'. All values are transformed from

double precision to exact numeric values N*2^e for integers N and e.

'r' stands for 'rational'

← 上一篇: 王者荣耀怎么看皮肤
下一篇: VR行业发展现状和未来前景分析 →

相关推荐

世界杯录像回放

世界杯录像回放

球迷吧(qiumiba.com)是一个免费的体育导航网站,仅为用户提供资源导航服务,所有视频及视听节目均为外链,跳转到第三方页面播放,球迷吧(qiumi

勒夫解释世界杯为啥不带萨内:他国家队表现太差

勒夫解释世界杯为啥不带萨内:他国家队表现太差

萨内的世界杯海报被撤掉 德国公布世界杯23人大名单时,没有曼城边锋萨内的名字。一时间球迷和媒体都爆炸了,不理解主教练勒夫的选择。《

认识沙巴州(Sabah)

认识沙巴州(Sabah)

马来西亚真正的探险地是位于婆罗州上的沙巴及砂拉越,这两州共同组成东马区。东马区拥有广大的雨林、长长的道路及河流、无限久远的老洞

如何成为一名侦探

如何成为一名侦探

资历及培训 成为侦探有几种不同的途径:研究生、职业侦探、警察和学徒。 资历及培训 一个人在成为侦探之前不需要先成为警察。对于毕业生来

补码原理——负数为什么要用补码表示

补码原理——负数为什么要用补码表示

文首 我们都知道负数在计算机中是以补码(忘了补码定义的戳这里)表示的,那为什么呢?本文尝试了解补码的原理,而要想理解它,首先得理

乐士洗衣机排行榜

乐士洗衣机排行榜

Copyright© 2020-2025深圳市云网万店电子商务有限公司版权所有| 苏公网安备 32010202010078号| 粤ICP备2021027996号 云网万店增值电信业务许可证-合字B2-202