Error in Matlab command line

Status
Not open for further replies.

evoplus

Member level 1
Joined
Dec 28, 2004
Messages
36
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
341
Matlab Question

Hi everyone,

I'm currently writing a matlab problem that has one of this command line x^4+c3*x^3+c2*x^2+c1*x+c0=0. My aim is to come up with the values of x. All the c3,c2,c1,c0 parameters have been properly defined. However it keeps showing the Error File that the assignment statements cannot produce a result. Could I ask why is this so?

Thanks
 

Re: Matlab Question

hi evoplus,
if you want solve this equation , you should enter >>roots([1 c3 c2 c1 c0])
in MATLAB command window till MATLAB find roots of your equation.
good luck.
 

Re: Matlab Question

m_mir said:
hi evoplus,
if you want solve this equation , you should enter >>roots([1 c3 c2 c1 c0])
in MATLAB command window till MATLAB find roots of your equation.
good luck.

Hi m_mir,

I tried ur suggestion inputing the roots ([1 c3 c2 c0]) after the x^4+c3*x^3+c2*x^2+c1*x+c0=0 but it still says that the assignment statement ( which is the x^4+c3*x^3+c2*x^2+c1*x+c0=0 ) cannot produce the result. All my c value can generate result. So have I missed out something?

Thanks
 

Matlab Question

Try this:
Code:
% Matlab code
c0=1;
c1=1;
c2=1;
c3=1;

equation=strcat('x^4+',num2str(c3),'*x^3+',num2str(c2),'*x^2+',num2str(c1),'*x+',num2str(c0),'=0')

solve(equation)
Code:
% Output
equation =

x^4+1*x^3+1*x^2+1*x+1=0


ans =
 
[  1/4*5^(1/2)-1/4+1/4*i*2^(1/2)*(5+5^(1/2))^(1/2)]
[ -1/4*5^(1/2)-1/4+1/4*i*2^(1/2)*(5-5^(1/2))^(1/2)]
[ -1/4*5^(1/2)-1/4-1/4*i*2^(1/2)*(5-5^(1/2))^(1/2)]
[  1/4*5^(1/2)-1/4-1/4*i*2^(1/2)*(5+5^(1/2))^(1/2)]
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…