TA的每日心情 | 开心 2019-11-29 15:38 |
---|
签到天数: 4 天 [LV.2]偶尔看看I
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
( H# t$ c y. C
2 Y# X# A: w5 S T- v' x3 d这是书上的一段代码,但是用18的matlab运行不了,想请教一下大神如何修改才能运行呢?感谢!
1 c7 d- O$ a: e( f- N4 f0 Tsyms a b x;
9 \7 _% c1 j% b9 |1 R3 @; df1=a*sin(x)+b8 R' i8 ~" T; V5 k: b3 M0 i
f2=subs(f1,sin(x),'log(y)')
8 b7 \2 M2 r# y" Yclass(f2)$ o# g) m5 e4 R
f3=subs(f1,a,sym(3.11))
7 |. e" F& I! r4 \class(f3)8 D! P0 I, x1 C0 g* N" a) C
f4=subs(f1,x,[0,pi/2,pi])
, u& b/ C# Z6 `class(f4)$ O$ Y* o, x E) K9 V% H
format
7 x7 K# O' `+ Qformat compact; K2 H* ^9 Z3 O& D4 R
t=0:pi/10:2*pi;
5 h! z# X6 S7 k$ o! uf5=subs(f1,{a,b,x},{2.3,t}); P+ |0 f4 R K$ F& ?: B5 t
class(f5)+ j. X/ {! k3 F) W7 k: o) h- d
plot(t,f5,'r:','LineWidth',5)
1 K6 v8 R' R) v$ Gk=[0.6;0.8;1];4 x# z, a: I/ T5 H
f6=subs(subs(f1,{a,b},{k,2}),x,t);: \3 c# ?" S6 q0 G3 l. M# G
class(f6)$ U3 y1 U* M/ c' o+ l9 \* T$ E
plot(t,f6)
9 {/ i, [/ L! @) e0 A3 c
) }/ i/ l: p" E* e3 p E3 E; R# r7 ]+ I7 O
提示错误信息8 o' |) d" Z: [5 N4 B6 d
错误使用 sym>convertChar (line 1448)
9 |5 [% N5 t; w/ H% OCharacter vectors and strings in the first argument can only specify a variable or number. To evaluate character vectors and strings$ j' `3 e) w0 T
representing symbolic expressions, use 'str2sym'.$ a7 B- T$ o( ~) i
8 r, ?/ }% `3 C* @
2 {- ]3 u0 r: `5 N6 o
出错 sym>tomupad (line 1214)
' Z: Z6 ?8 U) \: F S = convertChar(x);4 M! o3 l6 t4 U7 `2 \2 i
5 v5 [- w- Q0 E5 R# \
' w' |! O: U o; Z q5 v出错 sym (line 211): p; h( y( l) b" s
S.s = tomupad(x);
5 `: \+ Y& ? k% B7 v5 |2 Y6 q
r2 K2 F, |' a& u6 q; r7 @. x$ N# y/ F. ^) c+ u
出错 sym/subs>normalize (line 211)# R' `: y; |( W4 t. L
Y = {sym(Y)};
3 s& T1 B0 V' S6 Y" w
3 v0 h9 c. y! n; T% m
# x5 m' T( n6 G4 x& `出错 sym/subs>mupadsubs (line 157)# K6 @- u4 i1 G! U7 w+ p
[X2,Y2,symX,symY] = normalize(X,Y); %#ok
) X0 m( w/ o5 h0 S
* d# `/ t8 U7 J; h- a: I% T* [& \+ t6 Y) I% N5 v0 _5 ^
出错 sym/subs (line 145)
; n1 I7 i9 @5 S9 e) M$ [9 ^
' v% E. f. J0 ~) E G = mupadsubs(F,X,Y); |
|