Matrix Vandermonde Code

I am very interesting with polyfit code in Matlab. I try to convert this polyfit code in Matlab to C. When I try create code polyfit from Matlab to C, I get a function vander in Matlab. vander is Matlab function to create matrix vandermonde. After searching about matrix vandermonde, I try to create matrix vandermonde code in C. In linear algebra, a Vandermonde matrix, named after Alexandre-Théophile Vandermonde, is a matrix with the terms of a geometric progression in each row, i.e., an m × n matrix (from wikipedia). I get this equation to create matrix vandermonde code :

Output from this matrix vandermonde is a matrix 2D. You can read my last post about how to create 2D array in C/C++ in here. From my example to create Matrix Vandermonde, I create input array 1D with value [1 2 3 4 5]. This is my matrix vandermonde code in C. Save this code with name vandermonde.c.

You can save this code and compile this matrix vandermonde code with command :

gcc vandermonde.c -lm -o vandermonde

This is output from my matrix vandermonde code in C :

Output from this my  matrix vandermonde code in C is equal with output from Matlab.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.