필터 지우기
필터 지우기

Solve cubic equation in MATLAB

조회 수: 3 (최근 30일)
PRIYANK AGARWAL
PRIYANK AGARWAL 2012년 3월 24일
I need to solve a cubic equation but I don't know how to do it. Here is my coding:
B=80.73233784;
xc=152.01;
R=82.05746;
for i=1:0.1:200
x(i)=-50+i;
y(i)=(10^(7.23086-(1175.581/(x(i)+271.079))))*0.001315789473684;
a(i)=y(i)/(R*x(i));
b(i)=(4.9343*((xc/x(i))^1.5)*B)-B-((y(i)/(R*x(i)))*(B^2));
c(i)=4.9343*((xc/x(i))^1.5)*(B^2);
m=[a -1 b -c];
r=roots(m);
end
This is my equation to be solved for "v": ((a(i)*(v^3))-(v^2)+(b(i)*v)-c(i))=0;
Here "a", "b" and "c" changes with respect to "x" and "y". I want to eliminate the negative and complex roots but I am unable to do so. Moreover program shows error that roots can't be found. I am new to MATLAB and don't know much about its functions. Kindly help me. Thank you.

채택된 답변

Rick Rosson
Rick Rosson 2012년 3월 24일
>> doc roots
>> doc isreal
  댓글 수: 2
PRIYANK AGARWAL
PRIYANK AGARWAL 2012년 3월 25일
Thanks for replying. Sorry I don't know about these functions. Please tell me how to declare them and what are they used for.
Rick Rosson
Rick Rosson 2012년 3월 25일
Those are commands that you can type at the MATLAB command line. Please try it.

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

추가 답변 (0개)

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by