Solve a quadratic equation

3 visualizaciones (últimos 30 días)
Mepe
Mepe el 20 de Feb. de 2020
Comentada: Mepe el 20 de Feb. de 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?

Respuesta aceptada

Alex Mcaulley
Alex Mcaulley el 20 de Feb. de 2020
Editada: Alex Mcaulley el 20 de Feb. de 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
  1 comentario
Mepe
Mepe el 20 de Feb. de 2020
Works perfect. Thanks!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Partial Differential Equation Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by