Machine dynamics with Matlab

조회 수: 5 (최근 30일)
Nikhil A
Nikhil A 2020년 6월 17일
편집: Black Woods 2022년 10월 16일
Sir, I have doubt in solving this question from an exercise from edx course. It is Working with Symbolic Expressions and Functions, here I need to find the solution and solve the equation.
Question is in the pic.
syms x; % Define a symbolic variable x
f(x) = -x^3+x^2-x+5; % Define the required function
symEq = solve(f(x)) % Define a suitable equation for the problem
fplot(f,[0,10]) % Plot the function
sols = double(symEq) % Solve the solution
df=diff(f(x))
zero_crossing_complete = double(solve(df==0)) % Get the zero crossings of the equtation
zero_crossing_real = real(zero_crossing_complete) % Only extract the real zero crossings
The solution is as such,
symEq =
root(z^3 - z^2 + z - 5, z, 1)
root(z^3 - z^2 + z - 5, z, 2)
root(z^3 - z^2 + z - 5, z, 3)
sols =
-0.4406 - 1.5696i
-0.4406 + 1.5696i
1.8812 + 0.0000i
df =
- 3*x^2 + 2*x - 1
zero_crossing_complete =
0.3333 - 0.4714i
0.3333 + 0.4714i
zero_crossing_real =
0.3333
0.3333

답변 (1개)

Black Woods
Black Woods 2022년 10월 16일
편집: Black Woods 2022년 10월 16일
x = sym('x');
f(x) = [-x^3+x^2-x+5];
figure('WindowStyle','docked');
fplot(f(x),[0,10]);
axis('square')
sols = solve(f(x)==0);
zero_crossing_complete = double(sols);
zero_crossing_real = real(zero_crossing_complete(end,end));

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by