You are Here: Home >< Maths

# Matlab help watch

1. I'm fairly new to using matlab and I'm trying to plot log(x)=1/(x-1) however when I try this the graph is just not correct. My log(x) part looks as if it is going to approach 0 as it should but then it flicks away in the opposite direction. I have tried using the semi log and log log commands but nothing seems to work. If anyone could help that would be great
2. (Original post by Swizzel)
I'm fairly new to using matlab and I'm trying to plot log(x)=1/(x-1) however when I try this the graph is just not correct. My log(x) part looks as if it is going to approach 0 as it should but then it flicks away in the opposite direction. I have tried using the semi log and log log commands but nothing seems to work. If anyone could help that would be great
I presume you mean that you're trying to solve log(x)=1/(x-1)by graphical means? What commands are you using and what is the result?
Attached Images

3. (Original post by Gregorius)
I presume you mean that you're trying to solve log(x)=1/(x-1)by graphical means? What commands are you using and what is the result?
Yeah I'm trying to produce the plot you've attached! I've used
X=linspace(1,5,100)
Figure
Hold on
y1=(1./(x-1))
y2=log(x)
Plot(x,y1,x,log(x))
Hold off

This produces something very close to the correct graph but something isn't quite right with the log x part it looks as if it is going to tend towards 0 but then it flicks upwards and carries on travelling above the x-axis
4. (Original post by Swizzel)
Yeah I'm trying to produce the plot you've attached! I've used
X=linspace(1,5,100)
Figure
Hold on
y1=(1./(x-1))
y2=log(x)
Plot(x,y1,x,log(x))
Hold off

This produces something very close to the correct graph but something isn't quite right with the log x part it looks as if it is going to tend towards 0 but then it flicks upwards and carries on travelling above the x-axis
I've run this code (in the form below) and it does as it should...

x=linspace(1,5,100)

y1=(1./(x-1))
y2=log(x)

plot(x,y1,x,log(x)) (OR plot(x,y1,x,y2) !)
Attached Images

5. (Original post by Gregorius)
I've run this code (in the form below) and it does as it should...

x=linspace(1,5,100)

y1=(1./(x-1))
y2=log(x)

plot(x,y1,x,log(x)) (OR plot(x,y1,x,y2) !)
Sorry I actually meant x=linspace(-1,5,100). So I can see both the roots of the equation
6. (Original post by Swizzel)
Sorry I actually meant x=linspace(-1,5,100). So I can see both the roots of the equation
You will confuse the poor programme if you ask for the logarithm of a negative number! What I get from running your code is attached, which is not too surprising. Try using x=linspace(0,5,100) (or even better, x=linspace(0.001,5,100))
Attached Images

7. (Original post by Gregorius)
You will confuse the poor programme if you ask for the logarithm of a negative number! What I get from running your code is attached, which is not too surprising. Try using x=linspace(0,5,100) (or even better, x=linspace(0.001,5,100))
Thank you! That works now!

### Related university courses

TSR Support Team

We have a brilliant team of more than 60 Support Team members looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

This forum is supported by:
Updated: November 2, 2016
The home of Results and Clearing

### 1,021

people online now

### 1,567,000

students helped last year
Today on TSR

### University open days

1. Keele University
Sun, 19 Aug '18
2. University of Melbourne
Sun, 19 Aug '18
3. Sheffield Hallam University
Tue, 21 Aug '18
Poll
Useful resources

### Maths Forum posting guidelines

Not sure where to post? Read the updated guidelines here

### How to use LaTex

Writing equations the easy way

### Study habits of A* students

Top tips from students who have already aced their exams