Solve a quadratic equation
6 次查看(过去 30 天)
显示 更早的评论
So far I have solved the equation below with fsolve (with the help of this forum).
tau = 0.1
f4 = [3; 2; 6; 8]
f8 = [2; 6; 7; 3]
eq = @(s,f4,f8) s*tau-(0.1.*s^2+3.54.*s-9.53).*f4.^2-f8;
for f = 1:1:length (f4)
F1 (f,:) = fsolve (@(s)eq(s,f4(f),f8(f)), 0);
end
Unfortunately, only a solution of the quadratic equation is given here. I didn't get along with the command roots () because my "formulas" were not accepted here. Does anyone have an idea here how elegantly all solutions can be found?
0 个评论
采纳的回答
Alex Mcaulley
2020-2-20
编辑:Alex Mcaulley
2020-2-20
To use the function roots you need to reformulate your equation:
tau = 0.1
f4 = [3; 2; 6; 8]
f8 = [2; 6; 7; 3]
eq = @(f4,f8) [-0.1*f4^2, -3.54*f4^2 + tau,9.53*f4^2-f8];
sol = zeros(numel(f4),2);
for f = 1:1:length(f4)
sol(f,:) = roots(eq(f4(f),f8(f)));
end
>> sol
sol =
-37.7542 2.4654
-37.3027 2.1527
-37.8394 2.4672
-37.8874 2.5030
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Quadratic Programming and Cone Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!