Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Integration in Matlab?

  1. May 22, 2015 #1
    Hi, I have a problem of integration in Matlab. I want to integrate the following equation:
    y=x/(exp(x)-1)
    and x is from 0 to 1.

    I use int(y,0,1), but it seems that it does not give correct result.
    Could you help me how to do it in Matlab? Thanks!
     
  2. jcsd
  3. May 22, 2015 #2

    Simon Bridge

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    Try constructing the sum.
     
  4. May 24, 2015 #3

    hunt_mat

    User Avatar
    Homework Helper

    Write your own integration routine. The use of Trapzium rule works very well in Matlab.
     
  5. May 24, 2015 #4
    >integral(@(x)x./(exp(x)-1),0,1)

    This is how you integrate in Matlab. It is ridiculous to implement your own algorithm for anything other than educational purposes.
     
  6. May 24, 2015 #5

    hunt_mat

    User Avatar
    Homework Helper

    It's good if the standard way is difficult implemented. I wrote all my own routines in matlab, even the Fourier transform bit.
     
  7. May 24, 2015 #6
    Quite a lot of effort goes into refining numerical methods. The optimization of your codes are without any doubt far inferior to what is already implemented by matlab. Also being able to learn the standard way to implement is a very crucial skill itself.
     
  8. May 24, 2015 #7

    hunt_mat

    User Avatar
    Homework Helper

    True enough, but things like the Fourier transform, don't give the Fourier transform, they give something else, and if you have no idea what they're doing, then you might as well write your own and understand what is going on.

    Don't get me wrong, there ARE a lot of routines that I trust matlab with without even thinking about writing myself, but some I just have no idea what is being done or the way that matlab implements it is impossible to code into your own routines.
     
  9. May 24, 2015 #8

    Simon Bridge

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    If there is some issue, as in this case, about the built-in approaches, then writing your own adds transparency and comparing different approaches can build confidence in a student.
    Note: the question above is in an educational context: it is for educational purposes that this approach has been suggested.
    Anyway - it's not difficult.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Integration in Matlab?
  1. On Integration (Replies: 4)

  2. An integral (Replies: 2)

Loading...