How to calculate gradient from semilogy plot graph?

I have data and already plotted in semilogy graph,
I need to know the gradient from that graph
Any one can help me, please?
I use Matlab 2016b versiaon

 채택된 답변

Torsten
Torsten 2022년 7월 14일

0 개 추천

In the left part, your functional equation is approximately
f(x) = 10^(-3.2*x+70)
I don't know from your question whether you mean the gradient of your original function f(x) or that of log10(f(x)) that is shown in the plot.

댓글 수: 5

y-axis is pressure data, and x-axis is time
I want to calculate the gradient or pressure
Then the gradient is
syms t
f = 10^(-3.2*t+70);
gradf = diff(f,t)
gradf = 
whatever the units for pressure and time in the plot might be.
But, there is a error warning
"Error using ^
Inputs must be a scalar and a square matrix.
To compute elementwise POWER, use POWER (.^) instead."
I tried to fix it : f = 10.^(-3.2*t+70);
but it still error with this note :
Error using diff
Difference order N must be a positive integer scalar.
There are negative value, do you have any advice to fix it?
I don't know what you try to do.
The linear part of the semilogy plot can be approximated by g(t) = 70-3.2*t.
Thus the original pressure function is
p(t) = 10^g(t) = 10^(70-3.2*t).
Now I just calculated its gradient symbolically:
syms t
p = 10^(70-3.2*t)
p = 
gradp = diff(p,t)
gradp = 
Or maybe you don't have a licence for the Symbolic Toolbox ?
Try
license checkout Symbolic_Toolbox
ans = 1
I think I made a mistake in the calculation of your pressure function.
I assumed that in the semilogy plot, log(p) is plotted against t. But that's not true - it's also p that is shown.
The following code should be correct:
b = log10(70);
a = log10(6/70)/30;
a = -0.0356
ans = 1.0853
syms t
p = 10^(a*t+b);
double(subs(p,t,0))
ans = 70.0000
double(subs(p,t,30))
ans = 6.0000
gradp = diff(p,t);
p = matlabFunction(p);
gradp = matlabFunction(gradp);
t = 0:0.1:40;
plot(t,p(t))
plot(t,gradp(t))

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

BELDA
BELDA 2023년 3월 1일

0 개 추천

1° question n°1 :
b = log10(70);
a = log10(6/70)/30;
Vous avez élévé la fonction f(x) en log base 10 c a d en échelle semilog alors que x est en échelle linéaire afin de mieux définir ma fonction f(x);
pourquoi pour a=log10(6/70)/30 comment on trouve (6/70)/30 pour -3.2x
D'avance merci .

댓글 수: 1

Torsten
Torsten 2023년 3월 1일
편집: Torsten 2023년 3월 1일
You search for the constants of a linear function a*x+b such that (from the graph)
p(0) = 10^(a*0+b) = 70
p(20) = 10^(a*20+b) = 6 (I don't know how I came up with p(30) = 6 as done above).
The equations are thus
70 = 10^b, thus b = log10(70) and
6 = 10^(a*20+b) -> log10(6) = a*20+log10(70) -> a = (log10(6)-log10(70))/20 = log10(6/70) / 20.
The original pressure curve is thus approximately
p(t) = 10^(log10(6/70) / 20 * t + log10(70))

댓글을 달려면 로그인하십시오.

카테고리

질문:

2022년 7월 14일

편집:

2023년 3월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by