# MATLAB Integration in Matlab?

Tags:
1. May 22, 2015

### leftbank007

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. May 22, 2015

### Simon Bridge

Try constructing the sum.

3. May 24, 2015

### hunt_mat

Write your own integration routine. The use of Trapzium rule works very well in Matlab.

4. May 24, 2015

### Wxfsa

>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.

5. May 24, 2015

### hunt_mat

It's good if the standard way is difficult implemented. I wrote all my own routines in matlab, even the Fourier transform bit.

6. May 24, 2015

### Wxfsa

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.

7. May 24, 2015

### hunt_mat

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.

8. May 24, 2015

### Simon Bridge

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.

Share this great discussion with others via Reddit, Google+, Twitter, or Facebook