Obtaining the minimum value of solutions

조회 수: 18 (최근 30일)
onsagerian
onsagerian 2018년 9월 3일
댓글: Star Strider 2018년 9월 3일
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

채택된 답변

Star Strider
Star Strider 2018년 9월 3일
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
onsagerian
onsagerian 2018년 9월 3일
Thank you for your explanation!
Star Strider
Star Strider 2018년 9월 3일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by