For Programmers: Free Programming Magazines  


Home > Archive > Matlab > April 2005 > solving polynomial









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author solving polynomial
Michael

2005-04-27, 9:01 pm

I need to be able to solve a 6th order polynomial for a large matrix
of values. I thought about using solve but this didnt work. The
problem is that when it uses solve it needs the value to be actually
entered and cant be previously defined.

Here is the form I had in mind and was hoping someone could tell me
how to make it work or work around this.

t = 0:0.1:100;
velc = -0.58611*t + 58.85789;
velc = velc';

for ii = 1:1001

velc = velc(ii);

[newv] = solve('-0.000393*x^6 + 0.012873*x^5 - 0.159027*x^4 +
0.875055*x^3 - 2.195467*x^2 - 2.899670*x + 88.000000 = velc');

end
Akshay Singh

2005-04-27, 9:01 pm

Michael:

See functions poly and roots.

For your case

for i = 1:1001,
poly=[-0.000393 0.012873 -0.159027 0.875055 -2.195467 -2.899670
88.000000-velc(i)];

result(i) = roots(poly);

end

=============================

Michael wrote:
>
>
> I need to be able to solve a 6th order polynomial for a large
> matrix
> of values. I thought about using solve but this didnt work. The
> problem is that when it uses solve it needs the value to be
> actually
> entered and cant be previously defined.
>
> Here is the form I had in mind and was hoping someone could tell me
> how to make it work or work around this.
>
> t = 0:0.1:100;
> velc = -0.58611*t + 58.85789;
> velc = velc';
>
> for ii = 1:1001
>
> velc = velc(ii);
>
> [newv] = solve('-0.000393*x^6 + 0.012873*x^5 - 0.159027*x^4 +
> 0.875055*x^3 - 2.195467*x^2 - 2.899670*x + 88.000000 = velc');
>
> end

Stefan

2005-04-27, 9:01 pm

maybe this:

help fzero

Regards,
Stefan

Michael wrote:
>
>
> I need to be able to solve a 6th order polynomial for a large
> matrix
> of values. I thought about using solve but this didnt work. The
> problem is that when it uses solve it needs the value to be
> actually
> entered and cant be previously defined.
>
> Here is the form I had in mind and was hoping someone could tell me
> how to make it work or work around this.
>
> t = 0:0.1:100;
> velc = -0.58611*t + 58.85789;
> velc = velc';
>
> for ii = 1:1001
>
> velc = velc(ii);
>
> [newv] = solve('-0.000393*x^6 + 0.012873*x^5 - 0.159027*x^4 +
> 0.875055*x^3 - 2.195467*x^2 - 2.899670*x + 88.000000 = velc');
>
> end

Akshay Singh

2005-04-27, 9:01 pm

Ofcourse you dont want to use poly as a variable name.
Akshay

Akshay Singh wrote:[color=darkred]
>
>
> Michael:
>
> See functions poly and roots.
>
> For your case
>
> for i = 1:1001,
> poly=[-0.000393 0.012873 -0.159027 0.875055 -2.195467 -2.899670
> 88.000000-velc(i)];
>
> result(i) = roots(poly);
>
> end
>
> =============================
>
> Michael wrote:
The[color=darkred]
tell[color=darkred]
> me
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com