Turn on thread page Beta
    • Thread Starter
    Offline

    8
    ReputationRep:
    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
    Offline

    14
    ReputationRep:
    (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
     
    • Thread Starter
    Offline

    8
    ReputationRep:
    (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
    Offline

    14
    ReputationRep:
    (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
     
    • Thread Starter
    Offline

    8
    ReputationRep:
    (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
    Offline

    14
    ReputationRep:
    (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
     
    • Thread Starter
    Offline

    8
    ReputationRep:
    (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!
 
 
 
Reply
Submit reply
Turn on thread page Beta
Updated: November 2, 2016
The home of Results and Clearing

1,021

people online now

1,567,000

students helped last year

University open days

  1. Keele University
    General Open Day Undergraduate
    Sun, 19 Aug '18
  2. University of Melbourne
    Open Day Undergraduate
    Sun, 19 Aug '18
  3. Sheffield Hallam University
    City Campus Undergraduate
    Tue, 21 Aug '18
Poll
A-level students - how do you feel about your results?
Useful resources

Make your revision easier

Maths

Maths Forum posting guidelines

Not sure where to post? Read the updated guidelines here

Equations

How to use LaTex

Writing equations the easy way

Student revising

Study habits of A* students

Top tips from students who have already aced their exams

Study Planner

Create your own Study Planner

Never miss a deadline again

Polling station sign

Thinking about a maths degree?

Chat with other maths applicants

Can you help? Study help unanswered threads

Groups associated with this forum:

View associated groups

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.