Machine dynamics with Matlab

6 ビュー (過去 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 Center および File ExchangeSymbolic Math Toolbox についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by