Effacer les filtres
Effacer les filtres

Error in command for partial differentiation

1 vue (au cours des 30 derniers jours)
Sergio Manzetti
Sergio Manzetti le 14 Juil 2017
Commenté : Walter Roberson le 29 Déc 2017
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...

Réponses (3)

Jan
Jan le 14 Juil 2017
Modifié(e) : Jan le 14 Juil 2017
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 commentaires
Tam Ho
Tam Ho le 29 Déc 2017
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!
Walter Roberson
Walter Roberson le 29 Déc 2017
What is fit_v2 ?

Connectez-vous pour commenter.


Sergio Manzetti
Sergio Manzetti le 14 Juil 2017
John ,please see closer, I have removed one redundant bracket after the y at the beginning, otherwise, it is fine:
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))
Nothing is missing here or superfluous

Sergio Manzetti
Sergio Manzetti le 14 Juil 2017
Modifié(e) : Walter Roberson le 29 Déc 2017
Have a look at this short example:
>> diff((exp(-i*(x+y)), x))
diff((exp(-i*(x+y)), x))
Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.
  1 commentaire
Walter Roberson
Walter Roberson le 29 Déc 2017
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()

Connectez-vous pour commenter.

Catégories

En savoir plus sur Formula Manipulation and Simplification dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by