I am trying to get MATLAB to be able to produce a symbolic polynomial and am having some issues. The polynomial I would like it to produce is given a d and k,(adsbygoogle = window.adsbygoogle || []).push({});

X^{(k+1)}-X^{(k-d)}-X^{(k-d-1)}-...-1

What I have so far is

This code is the example where k = 5, d = 3. The first while loop generates the terms of the polynomial, the second is meant to generate the polynomial, but it is not working.Code (Text):k = 5;

d = 3;

syms X;

i = 0;

while (k-(d+i) >= 0)

terms(i+1) = k-(d+i);

i = i+1;

end

for j=1:i

poly = X^(k+1);

poly = inline(poly - X^(terms(j)));

end

In this example, the desired polynomial is

X^{6}-X^{2}-X-1

What the code is producing is

X^{6}-1

Any ideas on what I can do to produce the correct polynomial?

Thanks in advance.

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# MATLAB Polynomial Problem

Loading...

Similar Threads for MATLAB Polynomial Problem |
---|

MATLAB MATLAB: forces acting on an object |

MATLAB Matlab histogram |

MATLAB Sovling Bernoulli's differential equation in matlab? |

MATLAB Matlab-like software |

MATLAB Matlab data into bins |

**Physics Forums | Science Articles, Homework Help, Discussion**