作业帮 > 综合 > 作业

Matlab中subs函数的使用

来源:学生作业帮 编辑:灵鹊做题网作业帮 分类:综合作业 时间:2024/04/29 16:44:39
Matlab中subs函数的使用
syms x w b t;
x=dsolve('D2x+2*b*Dx+w^2*x=0','Dx(0)=4,x(0)=0');
dx=diff(x,t);
w=2;
b=0.1;
x1=subs(x);
dx1=subs(dx);
t=0:0.1:100;
xt=subs(x1,t);
dxt=subs(dx1,t);
subplot(221);
plot(t,xt);
subplot(222);
subplot(222);
plot(xt,dxt)
其中四次用到subs函数,
Matlab中subs函数的使用
R = subs(S) replaces all occurrences of variables in the symbolic expression S with values obtained from the calling function, or the MATLAB workspace.
相当于于用值去替换符号表达式中的变量
例如:
The statement
y = dsolve('Dy = -a*y')
produces
y =
C2/exp(a*t)
Then the statements
a = 980; C2 = 3; subs(y)
produce
ans =
3/exp(980*t)