increase accuracy and decrease numerical problems with "roots" function in matlab function block in Simulink
5 次查看(过去 30 天)
显示 更早的评论
Hello matlab and Simulink community,
i doing a project in simulik, in the project i need to solve quartic equation a*x^4+b*x^3+c*x^2+d*x+e=0 when a,b,c,d,e are real numbers that change in time a(t),b(t),c(t),d(t),e(t), so i need to solve quartic equation many times.
in order to solve the quartic equation i use "roots" in a matlab function block in simulink.
the code in the matlab function block is:
#start
function [r] = fcn(a,b,c,d,e)
p = [a b c d e];
r = roots(p)
#finish
i want to increase accuracy and decrease numerical problems in order to get the roots of the eqation as percise as possible, and also with more digits of percision.
i try to use "vpa" with "roots" but it does not work.
i would like to get some help =)
0 个评论
回答(1 个)
Keshav
2023-4-11
Hi Ram,
I understand that you are using MATLAB “roots” function to find the root of a polynomial equation. And you want to increase the accuracy and precision of the root. Please try to use MATLAB “vpasolve” function to find the root of polynomial equation.
You can find the MATLAB documentation for “vpasolve” function on the below link: https://www.mathworks.com/help/symbolic/sym.vpasolve.html?s_tid=srchtitle_vpasolve_1
Example of vpasolve (Let’s suppose you want to find the root of equation x^2 + 2*x + 3 = 0 with 40 digit precision)
syms x
digits(40)
vpasolve(x^2 + 2*x + 3 == 0,x);
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!