Borrar filtros
Borrar filtros

Obtaining the minimum value of solutions

9 visualizaciones (últimos 30 días)
onsagerian
onsagerian el 3 de Sept. de 2018
Comentada: Star Strider el 3 de Sept. de 2018
Hello,
I would like to collect the "minimum value" of each positive solution corresponding to each "n". After running the program, there are series of solutions for each "n". Would you let me know the way of obtaining the minimum value among the series of solution?
format long e
T=0.1;
k=1.0;
k_1=0.2;
k_2=0.1;
a_p=0.0001;
k_p=a_p/10;
a_q=0.00015;
k_q=0.00002;
theta=0.01;
m1=0.0000005;
m2=0.0000002;
W=0.00002;
syms x
gamma=(a_p*k*k_2)/(k_p*m1*k_1);
for n=1:1:10
equation=[(1+sqrt(gamma*theta^n))/sqrt(gamma+sqrt(theta^n))]^2-[(theta+x)/(1+x)]^(n+1)==0;
sol=vpasolve(equation,x);
fprintf('%d\n',n);
fprintf('%.10e\n',sol(sol>0.0)); <======= Any additional command to take "minimum value" of the solution?
end

Respuesta aceptada

Star Strider
Star Strider el 3 de Sept. de 2018
The ‘minimum’ depends on how you want to define it. Most of the results returned in ‘sol’ are complex, and the min function will return the value with the smallest magnitude (absolute value).
See the documentation section on Smallest Complex Element (link) for details.
In the interim, see if this will do what you want:
fprintf('%.10e\n',min(sol(sol>0.0)));
Experiment to get the result you want.
  2 comentarios
onsagerian
onsagerian el 3 de Sept. de 2018
Thank you for your explanation!
Star Strider
Star Strider el 3 de Sept. de 2018
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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