[Matlab 您所在的位置:网站首页 matlab中符号函数怎么求值 [Matlab

[Matlab

2023-09-03 20:17| 来源: 网络整理| 查看: 265

[Matlab-1]符号函数和数值函数fplot&plot 符号函数(symbolic method)数值方法(numerical method)一些栗子阶跃函数脉冲函数真·三角函数(triangular signal)sinc函数小结 在matlab里有两种生成函数的方法,一种是数值方法,一种是符号方法。两者都有配套的函数不可以混用,所以对于两种函数的理解显得格外重要

符号函数(symbolic method)

matlab主要是靠syms和sym函数来实现符号函数的生成,但是两者有些稍微的不同 在这里插入图片描述 注意到符号函数的打印函数为fplot而不是plot 如果我们要生成sin(pi/4*t)函数

syms t; %define the symbolic variable t y = sin(pi/4*t); %synbolic function fplot(y,[-16,16]) %plotting

如果要用sym的话可以这样(并不是很推荐用这个,可能会出一些问题,建议大家用syms)

f = sym('sin(pi/4*t)'); %define symbolic function fplot(f,[-16,16]); %plotting 数值方法(numerical method)

注意对于数值方法来说我们需要先定义一个区间并且定义步长,因为最终得到的是一组离散的值然后由平滑曲线连接而成的图像。注意使用的是plot函数,与fplot不同是需要带一个自变量,因为fplot里面的表达式自带了自变量。 还是以上面的三角函数的例子为例

t = -5:0.1:5; %define the time range t y = sin(pi/4*t); %numeric function plot(t,y) %plotting 一些栗子 阶跃函数

即u(t)=1 , t>=0 u(t) = 0, else

t=-1:0.01:5; t0=0; ft=(t>=t0); plot(t,ft);grid on;axis([-1,5,-0.5,1.5]); hold on; t1=0; ft = stepfun(t,t1); plot(t,ft, '--'); hold off; title(' Step function'); xlabel('t'); ylabel('f(t)'); 脉冲函数 t = -5:0.01:5; d = dirac(t); subplot(2,1,1); plot(t,d) syms t d = dirac(t); subplot(2,1,2); fplot(d); 真·三角函数(triangular signal)

ft=tripuls(t,w,s) w for width s for skew:-1



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有