The graph that i get looks very wrongCode:`x1=-10:.1:10;`

y1=exp(x1) - (7*x1);

plot(x1,y1);

How can i resolve this issue

Please help.

Printable View

- May 26th 2010, 07:18 AMAUCCmatlab plot functionCode:
`x1=-10:.1:10;`

y1=exp(x1) - (7*x1);

plot(x1,y1);

How can i resolve this issue

Please help. - May 26th 2010, 07:27 AMLaurent
The graph IS correct. But give a look at the scale on the vertical axis... Problem is that for x=10, is huge, so that we can't even distinguish (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. - May 26th 2010, 07:41 AMAUCC
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. - May 26th 2010, 07:45 AMLaurent
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.

- May 26th 2010, 08:03 AMAUCC
oh thanks. Now i got it.