Solve a quadratic equation
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mepe
am 20 Feb. 2020
Kommentiert: Mepe
am 20 Feb. 2020
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 Kommentare
Akzeptierte Antwort
Alex Mcaulley
am 20 Feb. 2020
Bearbeitet: Alex Mcaulley
am 20 Feb. 2020
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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Quadratic Programming and Cone Programming finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!