how can i get a slope in the loglog plot?

i enter the data in "ID"
ID = [ 2.33879000000000e-19,
7.68704000000000e-17,
.....
0.00865008100000000,
0.00892525100000000,
0.00920535600000000 ] ( for ID(1,1)~ID(600,1))
loglog(ID);
i get a loglog plot for data ID,
and i want to get a slope of this loglog plot (at all point)
and i want to get a graph for this slope data
how can i do this?

 Accepted Answer

Torsten
Torsten on 14 Sep 2022
Edited: Torsten on 14 Sep 2022
ID = ...;
dID = gradient(log10((1:600).'),log10(ID));
loglog(ID)
hold on
plot(log10((1:600).'),dID)

5 Comments

준형 박
준형 박 on 14 Sep 2022
Edited: 준형 박 on 14 Sep 2022
i cant get the graph i want , help
ex) in the plot, loglog(ID), ID.1 (570, 2.35232) , ID.2(121, 0.00139276)
The regime between the two points appears linear in loglog plot, and calculating the slope with a calculator shows about 4.795.
but in plot(log((1:600).'),dID), dID's value is about 0.2
how can i get 4.795?
Torsten
Torsten on 14 Sep 2022
Edited: Torsten on 14 Sep 2022
Do you want the slope in the original scale
slope = gradient((1:100).',ID) = (ID(i+1)-ID(i-1))/2 (i=2,...,length(ID)-1)
or in the loglog scale
slope = gradient(log((1:100).'),log(ID)) = (log(ID(i+1))-log(ID(i-1)))/(log(i+1)-log(i-1)) (i=2,...,length(ID)-1)
And I think log10 instead of log is required:
slope = gradient(log10((1:100).'),log10(ID))
if you want the latter (see above).
?
thank you for answer
i want to get loglog plot slope
when I get 4.795, I use this equation >> log(2.35232/0.00139276) / log(570/121) = 4.795 (use calculator)
but
when i use this
slope = gradient(log10((1:100).'),log10(ID));
i get a slope value about 0.1 ~ 0.2 .. why?
(log(ID(i+1))-log(ID(i-1)))/(log(i+1)-log(i-1))
I think this equation is the same as my intention
but i can't get slope data
Why log(570/121) ?
If you use loglog(ID), you get a graph with x-coordinates log10(i) and y-coordinates log10(ID(i)).
The slope in a single x-coordinate is thus approximately log10(ID(i+1)/ID(i-1))/log10((i+1)/(i-1)).
But the difference between 570 and 121 is not 2 ( (i+1) - (i-1) = 2).
Or do you have an independent x-vector and you use
loglog(x,ID)
?
Because in your first contribution, you wrote loglog(ID) as plot command.
If you just want to calculate d(log10(ID))/d(log10(x)) between two given points as I suspect, then
i1 = 3;
i2 = 54;
slope_i2_i1 = log10(ID(i2)/ID(i1))/log10(i2/i1)
is the way to go.
But this is not the pointwise slope (thus an approximation to the loglog derivative).
준형 박
준형 박 on 15 Sep 2022
Edited: 준형 박 on 15 Sep 2022
OK I understand
I think i misunderstood about x-coordinate
thank you for the reply.

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Asked:

on 14 Sep 2022

Edited:

on 15 Sep 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!