Error in command for partial differentiation
2 次查看(过去 30 天)
显示 更早的评论
Hi, I am trying to run this simple command:
y*(x*(exp(-i*(x+y)) - diff((exp(-i*(x+y)), x)) - x*diff((exp(-i*(x+y)), y) + diff((exp(-i*(x+y)), x, y)
however MATLAB doesn't take it and says:
Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.
However, the brackets are balanced...
0 个评论
回答(3 个)
Jan
2017-7-14
编辑:Jan
2017-7-14
Seriously? Matlab tells you clearly, that the parenthesis are not balanced and you do not believe it?
c = ['y*(x*(exp(-i*(x+y)) - diff((exp(-i*(x+y)), x)) - ', ...
'x*diff((exp(-i*(x+y)), y) + diff((exp(-i*(x+y)), x, y)']
sum(c == '(') % >> 16
sum(c == ')') % >> 12
There are 4 unclosed parenthesis. Ups. I recommend to trust Matlab's error messages.
3 个评论
Tam Ho
2017-12-29
I ran this code:
syms theta %create symbolic variable theta
assume(theta,'real') %theta is real
f = fit_v2; %calling our fitted polynomials
g = diff(f,theta);
g0=solve(g,theta);
double(g0);
I get this error:
Error in sym (line 215)
S.s = tomupad(x);
Error in sym/privResolveArgs (line 988)
argout{k} = sym(arg);
Error in sym/diff (line 21)
args = privResolveArgs(S,varargin{:});
Error in code (line 54)
g = diff(f,theta);
please help! Thanks!
Sergio Manzetti
2017-7-14
编辑:Walter Roberson
2017-12-29
1 个评论
Walter Roberson
2017-12-29
diff(exp(-i*(x+y)), x)
or
diff((exp(-i*(x+y))), x)
If you examine
diff((exp(-i*(x+y)), x))
you will see that the first argument is
(exp(-i*(x+y)), x)
which is an invalid sequence, since MATLAB does not permit expression comma expression inside anything other than [] or {} . You are also not passing a second argument to diff()
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!