Results 1 to 5 of 5

Math Help - matlab plot function

  1. #1
    Newbie
    Joined
    Apr 2010
    Posts
    23

    matlab plot function

    Code:
    x1=-10:.1:10;
    y1=exp(x1) - (7*x1);
    plot(x1,y1);
    The graph that i get looks very wrong

    How can i resolve this issue

    Please help.
    Attached Thumbnails Attached Thumbnails matlab plot function-matlabplot.jpg  
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor

    Joined
    Aug 2008
    From
    Paris, France
    Posts
    1,174
    Quote Originally Posted by AUCC View Post
    Code:
    x1=-10:.1:10;
    y1=exp(x1) - (7*x1);
    plot(x1,y1);
    The graph that i get looks very wrong

    How can i resolve this issue

    Please help.
    The graph IS correct. But give a look at the scale on the vertical axis... Problem is that for x=10, \exp(x) is huge, so that we can't even distinguish -70 (which would be the value for x=-10, approx.) from 0.

    "Solution" is to adjust the extent of the values x is assumed to take: choose x1=-10:.1:5 instead, for instance.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Apr 2010
    Posts
    23
    Well i didn't focus on the shape of the graph for positive values for x

    For negative values of x the graph looks very very wrong

    at x values lesser than zero the graph should go in the upward direction but the graph that mat-lab gives me lies on the x axis.

    Please help me.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    MHF Contributor

    Joined
    Aug 2008
    From
    Paris, France
    Posts
    1,174
    Quote Originally Posted by AUCC View Post
    Well i didn't focus on the shape of the graph for positive values for x

    For negative values of x the graph looks very very wrong

    at x values lesser than zero the graph should go in the upward direction but the graph that mat-lab gives me lies on the x axis.
    That's what I said. Matlab scales the axes so that the plot fits inside the window. The values for positive x are huge, so that Matlab has to choose a very large scale (I mean, which grows very quickly). On the other hand, on such a scale, the positive slope for negative x looks horizontal because it is not very steep. Make the change I recommended, and then maybe you'll get what I mean.
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie
    Joined
    Apr 2010
    Posts
    23
    oh thanks. Now i got it.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. plot of a function of time a matlab question
    Posted in the Math Software Forum
    Replies: 7
    Last Post: December 12th 2011, 01:12 PM
  2. 3D plot of z = (Matlab)
    Posted in the Math Software Forum
    Replies: 4
    Last Post: July 14th 2011, 09:22 PM
  3. Kac Formula plot with MatLab
    Posted in the Math Software Forum
    Replies: 1
    Last Post: March 14th 2010, 08:33 AM
  4. [Matlab] 2D Sequence Plot in 3D
    Posted in the Math Software Forum
    Replies: 2
    Last Post: April 23rd 2009, 05:28 AM
  5. MatLab Plot
    Posted in the Math Software Forum
    Replies: 1
    Last Post: August 2nd 2008, 11:59 AM

Search Tags


/mathhelpforum @mathhelpforum