Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
slope of a log log scale graph

Subject: slope of a log log scale graph

From: Nor Faizah

Date: 11 Apr, 2008 06:52:02

Message: 1 of 4

Hello

I have plotted a log log scale graph and would like to find
the slope for a certain range on the graph. How do I find
it without calculating it manually (by taking two points on
the graph and apply the formula m=dy/dx) ?

Many thanks.

Subject: slope of a log log scale graph

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 14 Apr, 2008 18:16:25

Message: 2 of 4

In article <ftn1qi$3ea$1@fred.mathworks.com>,
Nor Faizah <a7khawarizmi@yahoo.com> wrote:

>I have plotted a log log scale graph and would like to find
>the slope for a certain range on the graph. How do I find
>it without calculating it manually (by taking two points on
>the graph and apply the formula m=dy/dx) ?

If you have the equation of the graph and it is continuous,
you could take the derivative.

When you say "manually", are you referring to visually picking out
the positions on the graph and working with the visual positions?
If so, then you can avoid doing it "manually" by getting the
XData and YData properties of the line or lineseries handle graphic
object which is the plot.

Or were you hoping that there was a matlab command already in
place to do this for you, something akin to (the non-existant)
graphslope(linehandle,x1,x2,interpolationmethod)
The interpolation method would be optional; it would provide
guideance on how to project the corresponding y values when the
x values do not exactly match x data points already present.
--
  "No sincere artist was ever completely satisfied with his labour."
                                              -- Walter J. Phillips

Subject: slope of a log log scale graph

From: Roger Stafford

Date: 14 Apr, 2008 19:45:03

Message: 3 of 4

"Nor Faizah " <a7khawarizmi@yahoo.com> wrote in message <ftn1qi$3ea
$1@fred.mathworks.com>...
> Hello
>
> I have plotted a log log scale graph and would like to find
> the slope for a certain range on the graph. How do I find
> it without calculating it manually (by taking two points on
> the graph and apply the formula m=dy/dx) ?
>
> Many thanks.
--------
  When you say, "log-log", I believe you mean that originally there was a
function

  y = f(x) ,

but instead of plotting y against x, you have plotted Y = log(y) against X =
log(x). If that is the case, the slope you see on the graph is not the same as
the slope of the original function. They are related according to the equation

 dy/dx = (dy/dY)*(dY/dX)*(dX/dx)
       = y*dY/dX*(1/x) = (y/x)*M

where M is a slope (derivative) of the curve as it appears on the log-log
graph. This means for example that if you have what appears on the log-log
graph to be a straight line with slope M, the derivative of the original curve,
dy/dx, is related to this M by the above (varying) relation, and that would not
be a straight line in x and y coordinates. On the other hand, if you use the
values listed on log-log axes in determining slope, then that is indeed the
derivative of the original function itself. It all depends on what data you are
making use of, x and y, or X and Y.

  See the website:

<http://en.wikipedia.org/wiki/Logarithmic_scale#Log-log_plots>

for a discussion of this subject.

Roger Stafford

Subject: slope of a log log scale graph

From: Yi Cao

Date: 14 Apr, 2008 20:16:04

Message: 4 of 4

"Nor Faizah " <a7khawarizmi@yahoo.com> wrote in message
<ftn1qi$3ea$1@fred.mathworks.com>...
> Hello
>
> I have plotted a log log scale graph and would like to
find
> the slope for a certain range on the graph. How do I find
> it without calculating it manually (by taking two points
on
> the graph and apply the formula m=dy/dx) ?
>
> Many thanks.
>

I am not sure if the following example is what you looking
for:

x=logspace(-2,1,100);
y=1-exp(-x);
z=exp(-x);
dydx=diff(y)./diff(x);
loglog(x,y,x,z,x(2:end),dydx)
legend('y=f(x)','f''(x)','dy/dx','location','south')

hth
Yi Cao

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us