MATLAB Answers

How to get rid of sign() in diff() results?

24 views (last 30 days)
Valeri Aronov
Valeri Aronov on 6 Jun 2021
Edited: Paul on 29 Sep 2021 at 14:24
I have a symbolic function. diff() produces the result with sign(). The next derivative has dirac() in it. Is there a way to get rid of sign() in the diff() result?

Accepted Answer

Paul
Paul on 6 Jun 2021
If the goal is to get an expression for the amplitude of the frequency response of H(s) and then differentiate ...
syms R1 R2 C1 C2 w real
assume(R1>=0); assume(R2>=0); assume(C1>=0); assume(C2>=0);
syms s
H(s)=1/(C1*C2*R1*R2*s^2 + (C2*R1 + C2*R2)*s + 1);
A = abs(H(1j*w))
A = 
A = rewrite(A,'sqrt')
A = 
A_R1 = diff(A,R1)
A_R1 = 
A_R1_R1 = diff(A,R1,2)
A_R1_R1 = 
  3 Comments
Valeri Aronov
Valeri Aronov on 29 Sep 2021 at 13:18
Wow, Paul. May I apologize for unaccepting your original answer - it did answer the original question, after all. I thought that this way I will signal the new turn to you and preserve the context.
2021b result looks logical now.

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 6 Jun 2021
Not sure what you mean because you did not give any examples, but if you want the differences to always be positive, you can pass the results of diff() into abs():
d = abs(diff(v));
  4 Comments
Valeri Aronov
Valeri Aronov on 6 Jun 2021
The purpose is to get the latter - abs(H(jw)) wrt R1.

Sign in to comment.

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by