Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
differentiate

Subject: differentiate

From: mahshid

Date: 18 Oct, 2010 00:48:03

Message: 1 of 4

Hi there,

I have problem in differentiating an equation in my Matlab code, there is this error "Difference order N must be a positive integer scalar" when i use "diff" command to differentiate my Eq.
could u pls tell how i can do it?
tanx

Subject: differentiate

From: Roger Stafford

Date: 18 Oct, 2010 01:12:04

Message: 2 of 4

"mahshid " <mahshid770@yahoo.com> wrote in message <i9g5g3$ekp$1@fred.mathworks.com>...
> Hi there,
>
> I have problem in differentiating an equation in my Matlab code, there is this error "Difference order N must be a positive integer scalar" when i use "diff" command to differentiate my Eq.
> could u pls tell how i can do it?
> tanx
- - - - - - - - - - -
  Show in detail how you call on 'diff' and we'll show you how your "difference order" argument (the second argument) is not a positive integer scalar. Conceivably negative values could be interpreted as indefinite integrals (though they aren't,) but it is hard to visualize what a fractional order derivative might be.

Roger Stafford

Subject: differentiate

From: mahshid

Date: 18 Oct, 2010 01:58:04

Message: 3 of 4

Dear Roger,

tanx for replying, here is my eq :F=exp(a+b.*r.^0.5.*log(r+c./r+d.*phi+e.*phi.^1.5+f.*phi.^2+g.*phi.^2.*log(phi)+hh.*phi.^2.5+ii.*phi.^0.5);
with definite coefficient and i want to obtaine dF/dr, d2F/drd(phi) etc.
 ss=diff(F,r)
also i used "grad" the error was "Undefined function or method 'grad' for input arguments of type 'double'" could u pls tell what it means by "double" in this error?
regards,
Mahshid
"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i9g6t3$e2t$1@fred.mathworks.com>...
> "mahshid " <mahshid770@yahoo.com> wrote in message <i9g5g3$ekp$1@fred.mathworks.com>...
> > Hi there,
> >
> > I have problem in differentiating an equation in my Matlab code, there is this error "Difference order N must be a positive integer scalar" when i use "diff" command to differentiate my Eq.
> > could u pls tell how i can do it?
> > tanx
> - - - - - - - - - - -
> Show in detail how you call on 'diff' and we'll show you how your "difference order" argument (the second argument) is not a positive integer scalar. Conceivably negative values could be interpreted as indefinite integrals (though they aren't,) but it is hard to visualize what a fractional order derivative might be.
>
> Roger Stafford

Subject: differentiate

From: Roger Stafford

Date: 18 Oct, 2010 02:32:04

Message: 4 of 4

"mahshid " <mahshid770@yahoo.com> wrote in message <i9g9jc$6b4$1@fred.mathworks.com>...
> tanx for replying, here is my eq :F=exp(a+b.*r.^0.5.*log(r+c./r+d.*phi+e.*phi.^1.5+f.*phi.^2+g.*phi.^2.*log(phi)+hh.*phi.^2.5+ii.*phi.^0.5);
> with definite coefficient and i want to obtaine dF/dr, d2F/drd(phi) etc.
> ss=diff(F,r)
> also i used "grad" the error was "Undefined function or method 'grad' for input arguments of type 'double'" could u pls tell what it means by "double" in this error?
> regards,
> Mahshid
- - - - - - - - - -
  I am guessing you did not declare 'r' as a type 'sym', so 'diff' interpreted it as a numerical difference order, rather than the variable of differentiation, and it did not possess a positive integer value. Please read the documentation for 'diff' in the Symbolic Toolbox until you understand it completely.

  The 'grad' function is not meant for symbolic variables. It takes numerical differences and would not know how to deal with a symbolic expression.

  The "double" term refers to numerical floating point numbers which have double precision (64 bits) - in short, the usual numerical quantities used in matlab.

Roger Stafford

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us