TA的每日心情 | 开心 2019-11-29 15:38 |
---|
签到天数: 4 天 [LV.2]偶尔看看I
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
- v3 F# I+ _) c" l2 t* e" Z8 F' @6 L$ c: B4 J8 d
这是书上的一段代码,但是用18的matlab运行不了,想请教一下大神如何修改才能运行呢?感谢!
% F1 x4 x& j8 Osyms a b x;; W3 t- |# J% _" h. w
f1=a*sin(x)+b7 Z" Z6 H) t1 x! s/ j$ }
f2=subs(f1,sin(x),'log(y)')5 A& `& D8 _8 ~7 M
class(f2): I2 v0 W5 q$ d Y( K) @" f
f3=subs(f1,a,sym(3.11))
$ n. Y& y) k5 x' F5 |class(f3)/ |: I% U' K" X2 F% x7 l. u
f4=subs(f1,x,[0,pi/2,pi])
. W2 |) h. L# y7 t1 D; z- y' J; dclass(f4)7 M0 x/ z. D& Z2 Y
format
) E' ^* q7 H$ |2 z3 i9 Xformat compact
4 S& [2 ]! e& |4 ]% F$ ct=0:pi/10:2*pi;
) o. s, D8 ~+ o6 L* of5=subs(f1,{a,b,x},{2.3,t});" w5 J8 j) ]; n$ b5 U+ x% ~5 N
class(f5)
% u2 @8 m; j# K& d8 a+ Y! r6 D7 Zplot(t,f5,'r:','LineWidth',5)3 Q) s# {3 J6 u4 G3 _: }4 K, ^6 n
k=[0.6;0.8;1];4 G. h% X, |3 t1 l$ x+ X7 X
f6=subs(subs(f1,{a,b},{k,2}),x,t);
+ ^! W* ?5 y; z% ^* [, A, P% \; aclass(f6)
" u/ z$ W+ }; x: ~6 ]9 ]& o% ^plot(t,f6)" y) u+ H/ T( Z+ S
7 E- X: t2 ~5 a- o- x
# b! k e: r& w9 y2 r提示错误信息9 z3 G: U( i5 e) F5 U
错误使用 sym>convertChar (line 1448)
4 N0 j. f {8 ^Character vectors and strings in the first argument can only specify a variable or number. To evaluate character vectors and strings- Y% @ K8 N) ^- x# V
representing symbolic expressions, use 'str2sym'./ v' }1 @$ `! n" p0 B g6 c
/ s( B! T' W1 Z5 S6 [
3 ^3 a8 r% `' {: W4 f4 D% [( k
出错 sym>tomupad (line 1214)2 V, p8 T1 {" X) d
S = convertChar(x);
. A& k7 e% \; J: u+ O. T
4 G6 b( M+ H/ @# G% M5 E* y* W& o) M; e
出错 sym (line 211)& g: _1 ~7 m* ^5 V
S.s = tomupad(x);; x( l5 `) }+ j) }
/ @( `. G: R, v& s# a+ ^8 E
! q: D& `! w! n
出错 sym/subs>normalize (line 211)& G! T! f2 O V, e
Y = {sym(Y)};3 ]' ]. K5 T; R4 z, I
* I ^* G7 ~- Z! M0 _; J
3 V; Q6 }; g7 E8 _* W出错 sym/subs>mupadsubs (line 157)9 T- ^( ~% V# x) ~9 M
[X2,Y2,symX,symY] = normalize(X,Y); %#ok
9 r- K1 x9 |3 C( w! u; T" F
. U2 B5 z# C3 y
( P$ Z8 j8 z Q出错 sym/subs (line 145)8 G5 @& Y0 Z, B- }9 h A
/ ]& u! N S5 j& h2 J$ B G = mupadsubs(F,X,Y); |
|