Root finder solver for cubic equation

1 visualización (últimos 30 días)
Jamie Al
Jamie Al el 8 de Mzo. de 2021
Respondida: Walter Roberson el 8 de Mzo. de 2021
I have the following cubic equation in beta, knowing gamma, theta and M1 how can I find the roots of beta using MATLAB?
for example, knowing the following:
M1 = 8:3:20;
gamma = 1.4;
theta = 8;
  3 comentarios
Jamie Al
Jamie Al el 8 de Mzo. de 2021
Thanks David! I will try using roots and see how it goes.
Jamie Al
Jamie Al el 8 de Mzo. de 2021
I tried something like this, but I am not sure it's giving back correct roots
M1 = 8:3:20;
gamma = 1.4;
theta = 8; %in degrees
a = 1+((gamma-1)/2).*M1.^2.*tan(theta);
b = 1-M1.^2;
c = (1+((gamma-1)/2).* M1.^2).*tan(theta);
d = 1;
P = [a b c d];
bb = roots(P);
beta = atand(bb); %take inv of tan

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 8 de Mzo. de 2021
syms M1 gamma theta_degrees tanbeta_degrees
eqn = 1 + (gamma - 1)/2 * M1.^2 * tand(theta_degrees).*tanbeta_degrees.^3 + (1-M1.^2).*tanbeta_degrees.^2 + (1+(gamma+1)/2.*M1.^2);
solbeta = solve(eqn, tanbeta_degrees);
beta_degrees = atand(solbeta)
beta_degrees = 
M1_ = 8:3:20;
gamma_ = 1.4;
theta_degrees_ = 8; %in degrees
beta_values = subs(beta_degrees, {M1, gamma, theta_degrees}, {M1_, gamma_, theta_degrees_})
beta_values = 
beta_numeric = double(beta_values)
beta_numeric = 3×5
-47.7576 -47.4871 -47.3704 -47.3097 -47.2741 48.6681 48.3829 48.2600 48.1960 48.1586 88.3627 88.3749 88.3801 88.3828 88.3844
whos beta_numeric
Name Size Bytes Class Attributes beta_numeric 3x5 120 double
Here, the different columns correspond to the different M1 values, and the different rows correspond to the different roots of the cubic. Results are in degrees.

Más respuestas (0)

Categorías

Más información sobre Gamma Functions 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