Code Comments
Programming Forum and web based access to our favorite programming groups.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
Post Follow-up to this messageMichael:
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
Post Follow-up to this messagemaybe 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
Post Follow-up to this messageOfcourse you dont want to use poly as a variable name. Akshay Akshay Singh wrote: > > > 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 tell > me
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.