Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MATLAB Polynomial Problem

  1. Oct 25, 2011 #1
    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,


    What I have so far is

    Code (Text):
    k = 5;
    d = 3;
    syms X;

    i = 0;
    while (k-(d+i) >= 0)
        terms(i+1) = k-(d+i);
        i = i+1;

    for j=1:i
        poly = X^(k+1);
        poly = inline(poly - X^(terms(j)));
    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.

    In this example, the desired polynomial is


    What the code is producing is


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

    Thanks in advance.
  2. jcsd
  3. Oct 25, 2011 #2
    After some tinkering, I got it to work. If you would like to see the code, let me know.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook