# Finding all the zeroes of a discontinuous function in a particular range

조회 수: 5(최근 30일)
Aleem Andrew 27 Oct 2020 16:59
댓글: Star Strider 27 Oct 2020 19:18
I am trying to find the zeroes of the following symbolic function.
syms x
moment =20*heaviside(x - 8)*(x - 8) - (3*x^2*heaviside(x))/4 + 5*heaviside(x - 20)*(x - 20) +...
(3*heaviside(x - 20)*(x - 20)^2)/4;
fplot(diff(moment,1),[-2 20])
solve(diff(moment,1) == 0, x, 'MaxDegree', 4);
extrema = vpa(ans, 6)
subs(moment,extrema)
Matlabs outputs
extrema =
-1.0
ans =
0.0
However, the first derivative of the above moment function has a number of zeroes located at points other than -1, for example at approximately x = 13. Could someone please explain how all the zeroes or the zeroes in a particular range can be found?

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

### 채택된 답변

Star Strider 27 Oct 2020 17:14
It may be version-dependent.
In R2020b (Update 1), I get:
extrema =
13.3333
-1.0
ans =
-26.666666666666666666666666670975
0
Plotting the function as well as the derivative:
figure
fplot(diff(moment,1),[-2 20])
hold on
fplot(moment,[-2 20])
hold off
supports those.

#### 댓글 수: 2

Aleem Andrew 27 Oct 2020 19:09
Star Strider 27 Oct 2020 19:18
As always, my pleasure!

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

### Community Treasure Hunt

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

Start Hunting!

Translated by