|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
我在学习matlab符号运算这一章时尝试把书本的例子输入,发现是有误的,以下是从发现到修改的过程。
4 E6 S! s3 P: a1 N/ G/ x3 f- L; e- D
" U$ v1 q* T$ l; a' h5 a2 W2 v, j
$ ], i& C/ f7 k' r& B$ J**在这里>> a = sym('a');
0 k8 V0 l! ~) V8 y4 ]>> b = sym('b');) w; J7 e) b* n$ P# q; {2 d Z. }
>> x = sym('x'); B/ D8 O# h: q; W. m, F) L' R3 h
>> y = sym('y');
! n! g+ e' |9 _& w>> [x,y] = solve('a*x-b*y=1','a*x+b*y=3','x','y')**$ y% G3 X: w, C' E- `& s3 Y- C
! P8 ?/ ^8 U% w: Z1 A8 i7 h
4 X- e, ?) Y* I( @Error using solve>getEqns (line 418) {& i, j7 l4 s- d
List of equations must not be empty.. i7 R- G( a) u- T; v
6 s! T4 I2 v6 Q' D L( S- x+ BError in solve (line 226)
! {1 x* N0 d1 ?4 L, Y' c1 Z[eqns,vars,options] = getEqns(varargin{:});
; e& p3 G6 R- T: Z& X. y1 S/ G, V5 v+ e+ R1 N
**>> [x,y] = solve('a*x-b*y=1''a*x+b*y=3','x','y')%第二次尝试修改**
! P! W9 l, \4 o6 S+ y0 C
7 i1 z, D% S8 b0 eError using solve>getEqns (line 418)9 [" R$ C# \7 \1 K
List of equations must not be empty. F! Z# v9 P- f* R
Error in solve (line 226)" ~3 X( s* w2 y* h
[eqns,vars,options] = getEqns(varargin{:});# b0 H4 E& @( U
" S4 H3 y; h$ W# B \
**
& O! i/ W2 p; D" B, _1 l( w" O0 a: v+ X
>> [x,y] = solve(a*x-b*y=1,a*x+b*y=3,x,y) %第三次尝试修改
2 Y* y# M+ L7 `6 Q [x,y] = solve(a*x-b*y=1,a*x+b*y=3,x,y)
* o1 V; o' K! [6 @8 X+ ?5 q/ G! E+ ~# c7 [8 T
' j: C5 T) p7 m* a8 W4 H
**
0 J! R) F8 {4 N5 s- J1 Y8 `↑
. l- ]) |) e4 v) L8 G
t* J$ E5 D& w' ?/ lError: Incorrect use of ‘=’ operator. To assign a value to a variable, use ‘=’. To compare values for equality, use ‘==’.* U; B! [2 z) ]1 z! B/ x$ Q
0 r/ p! I$ e! O
>> [x,y] = solve(a*x-b*y== 1,a*x+b*y==3,x,y)%最终成功
9 g" L& h E; K' l8 t% t+ O: T0 V) h8 t \
x =
8 c: N+ w' G" w$ Y4 W' H
& H. m: M$ Y8 z: H2/a. K( d$ d& B7 T% \) ~; C0 G
0 p% o( Q5 H/ q' d. B# K
y =
3 u4 C. C4 l) v) M9 |7 {5 ^3 {% N. c: R. ^* z
1/b
) E5 J/ B3 i( h9 j& y& v
" Q2 {: u/ [. ?% J
9 [( [( F# |7 J4 `/ B+ F) f* Y. w" N* T3 F" n: H
|
|