Machine dynamics with Matlab
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/317715/image.png)
0 commentaires
Réponses (1)
Black Woods
le 16 Oct 2022
Modifié(e) : Black Woods
le 16 Oct 2022
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));
0 commentaires
Voir également
Catégories
En savoir plus sur Calculus dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!