×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

simple integration question

simple integration question

simple integration question

(OP)
Im new to matlab so you'll have to excuse the very basic question (and Im not sure if this is in the correct forum).

1) In the function polyint, there is 1 line of code to perform integration, and I can't see how it works. The line is-

r = [ p./(n:-1:1), 0 ];

where r is the integral being calculated, p is a row vector representing a polynomial (in the form of [1 0 0]) and n is the number of elements in p.

If someone could explain briefly what is happening it would be a big help. Thanks.

RE: simple integration question

It is simply integrating the polynomial as you would do yourself by hand. ie. int(A*x^n) = A/(n+1)*x^(n+1) + constant

Say p = [A B C D]

in a matlab polynomial this represents the polynomial

Ax^3 + Bx^2 + Cx + D.

Now the expression (n:-1:1) translates in matlab as "a vector whous elements count from n to 1 in steps of -1". ie, for n = 4 the vector

(n:-1:1) = [4 3 2 1]

so now

r = [p./(n:-1:1) ,0]

becomes

r = [ [A B C D]./[4 3 2 1] , 0]

the "X./Y" operator means "divide the element of X by the corresponding element of Y"

so now

r = [ [A/4 B/3 C/2 D/1], 0 ]

the ",0" bit means "append a 0 onto the end of the vector"

so r = [A/4 B/3 C/2 D/1 0]

which represents the matlab polynomial

(A/4)*x^4 + (B/3)*x^3 + (C/2)*x^2 + (D/1)*x + 0

and is the indefinite integral of p with the constant of integration set to zero.

M

--
Dr Michael F Platten

RE: simple integration question

(OP)
Thanks for the very prompt and helpful response! Even more simple than I thought now that I know what's going on..

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now