You can view the code for the polyfit function by typing the following in the MATLAB command window: >> edit polyfit
Then by viewing how "S" is created you can try to copy or adapt this code to fit your use.
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!