How to find a real positive root

조회 수: 8 (최근 30일)
Atom
Atom 2013년 4월 15일
How to find only the positive root of the equation x^3-A=0 for each A where A is a parameter varying like 1,2,3,....1000.
If alpha is the root, find the value of alpha/(alpha +1) for each case.

채택된 답변

Youssef  Khmou
Youssef Khmou 2013년 4월 15일
편집: Youssef Khmou 2013년 4월 15일
hi, try this essay :
counter=1;
for A=1:100
f=@(x) x^3-A;
alpha=fzero(f,A);
if isa(alpha,'complex');
continue;
else
X(counter)=alpha;
Y(counter)=alpha/(alpha+1);
counter=counter+1;
end
end
figure, plot(Y);
  댓글 수: 2
Atom
Atom 2013년 4월 15일
편집: Atom 2013년 4월 15일
Thanks for your answer. If the equation is of higher degree having -ve root, then how to avoid the negative root as well in order to get only the positive root?
Youssef  Khmou
Youssef Khmou 2013년 4월 16일
add the condition : if isa(alpha,'complex') && (g>=0)

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by